using Newtonsoft.Json; using NUnit.Framework; using TINK.Repository; using TINK.Repository.Response; namespace TestShareeLib.Repository { [TestFixture] public class TestCopriCallsStatic { [Test] public void TestDeserializeResponse_Factory_SupportedVersion() { var response = @" { ""shareejson"" : { ""copri_version"" : ""4.1.5.7"" } }"; Assert.That( response.DeserializeResponse(version => new ResponseBase()).copri_version, Is.EqualTo("4.1.5.7")); } [Test] public void TestDeserializeResponse_Factory_UnspportedVersion() { // Future version var response = @" { ""shareejson"" : { ""copri_version"" : ""4.2.5.7"" } }"; var factoryObject = JsonConvert.DeserializeObject>( @"{ ""shareejson"" : { ""copri_version"" : ""9.9.9.9"" } }"); Assert.That( response.DeserializeResponse(version => factoryObject).shareejson.copri_version, Is.EqualTo("9.9.9.9")); } [Test] public void TestDeserializeResponse_Exception_SupportedVersion() { // Future version var response = @" { ""shareejson"" : { ""copri_version"" : ""4.1.5.7"" } }"; Assert.That( response.DeserializeResponse(version => new System.Exception("hello")).copri_version, Is.EqualTo("4.1.5.7"), "No exception must be thrown because version 4.1.x is supported."); } [Test] public void TestDeserializeResponse_Exception_UnspportedVersion() { var response = @" { ""shareejson"" : { ""copri_version"" : ""4.2.5.7"" } }"; Assert.That( () => response.DeserializeResponse(version => new System.Exception("Ho")).copri_version, Throws.InstanceOf()); } } }