public void CallWebServiceGetTest()
        {
            ServiceBaseObjectService service = new ServiceBaseObjectService();

            try
            {
                // Test exception is thrown.
                service.CallWebServiceGetTestMethod(null);
                Assert.Fail();
            }
            catch (AggregateException ex)
            {
                Assert.AreEqual("requestUri", ((ArgumentNullException)ex.Flatten().InnerException).ParamName);
            }
            catch (Exception)
            {
                Assert.Fail();
            }

            var moqAdapter = new Mock <IMtgApiServiceAdapter>();

            moqAdapter
            .SetupSequence(x => x.WebGetAsync <RootCardDto>(It.IsAny <Uri>()))
            .ReturnsAsync(new RootCardDto());

            service = new ServiceBaseObjectService(moqAdapter.Object);

            var result = service.CallWebServiceGetTestMethod(new Uri("http://fake/url"));
        }
        public void ContructorTest()
        {
            ServiceBaseObjectService service;
            PrivateObject            privateObject;

            service       = new ServiceBaseObjectService();
            privateObject = new PrivateObject(service, new PrivateType(typeof(ServiceBase <CardService, Card>)));
            Assert.IsInstanceOfType(privateObject.GetFieldOrProperty("Adapter"), typeof(MtgApiServiceAdapter));
            Assert.AreEqual(ApiVersion.V1_0, privateObject.GetFieldOrProperty("Version"));
            Assert.AreEqual(ApiEndPoint.Cards, privateObject.GetFieldOrProperty("EndPoint"));
        }
        public void BuildUriTest()
        {
            ServiceBaseObjectService service       = new ServiceBaseObjectService();
            PrivateObject            privateObject = new PrivateObject(service, new PrivateType(typeof(ServiceBase <CardService, Card>)));

            // Test passing in a NameValueCollection.
            try
            {
                // Test exception is thrown.
                privateObject.Invoke("BuildUri", new Type[] { typeof(NameValueCollection) }, new object[] { null });
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("parameters", ex.ParamName);
            }
            catch
            {
                Assert.Fail();
            }

            NameValueCollection parameters = new NameValueCollection();

            parameters["name"]     = "fakename";
            parameters["address"]  = "123fakestreet";
            parameters["province"] = "fakeprovince";

            var url = privateObject.Invoke("BuildUri", new Type[] { typeof(NameValueCollection) }, new object[] { parameters }) as Uri;

            Assert.AreEqual(new Uri("https://api.magicthegathering.io/v1/cards?name=fakename&address=123fakestreet&province=fakeprovince"), url);

            // Test passing in a parameter value.
            try
            {
                // Test exception is thrown.
                privateObject.Invoke("BuildUri", new Type[] { typeof(string) }, new object[] { null });
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("parameterValue", ex.ParamName);
            }
            catch
            {
                Assert.Fail();
            }

            url = privateObject.Invoke("BuildUri", new Type[] { typeof(string) }, new object[] { "100" }) as Uri;
            Assert.AreEqual(new Uri("https://api.magicthegathering.io/v1/cards/100"), url);
        }