public void WebserviceResultExceptionTest()
        {
            var wrapper = new CatWebserviceWrapper(Service);
            IWebserviceResult result = wrapper.WritePrice(TestHelper.GetPriceWebsiteDescription());

            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.ServiceMessage, result.ServiceMessage);
        }
        public void GetLoginStatusTest()
        {
            var wrapper = new CatWebserviceWrapper(Service);

            wrapper.Connect();
            Assert.AreEqual("Logged In", wrapper.GetLoginStatus());

            wrapper.Disconnect();
            Assert.AreEqual("Not Logged In", wrapper.GetLoginStatus());
        }
        public void WriteProductWithEmptyDescription()
        {
            var wrapper = new CatWebserviceWrapper(Service);

            wrapper.Connect();

            IWebserviceResult webserviceResult = wrapper.WriteProduct(TestHelper.GetEmptyProductWebsiteDescription());

            Assert.IsTrue(webserviceResult.HasErrors, webserviceResult.ServiceMessage);
        }
        public void DeleteNonExistingProductFromWebsite()
        {
            var wrapper = new CatWebserviceWrapper(Service);
            ProductWebsiteDescription description = TestHelper.GetEmptyProductWebsiteDescription();

            wrapper.Connect();

            IWebserviceResult webserviceResult = wrapper.WriteProduct(description);

            Assert.IsTrue(webserviceResult.HasErrors, webserviceResult.ServiceMessage);
        }
        public void DeleteAllBarriersForNonExistingValor()
        {
            var wrapper = new CatWebserviceWrapper(Service);
            IWebserviceResult connect = wrapper.Connect();

            Assert.IsFalse(connect.HasErrors, connect.ServiceMessage);
            Assert.IsTrue(wrapper.IsConnected);

            IWebserviceResult deleteBarriers = wrapper.DeleteBarriers(Settings.Default.InvalidValor);

            Assert.IsTrue(deleteBarriers.HasErrors);
        }
        public void WritePriceOnDisconnectedServiceTest()
        {
            var wrapper = new CatWebserviceWrapper(Service);
            PriceWebsiteDescription price = TestHelper.GetPriceWebsiteDescription();

            Assert.AreEqual(WebserviceWrapperState.Disconnected, wrapper.WebserviceState);

            IWebserviceResult webserviceResult = wrapper.WritePrice(price);

            Assert.IsTrue(webserviceResult.HasErrors);
            Assert.IsNotNull(webserviceResult.RequestInfo);
        }
        public void WritePriceForOnlineProductTest()
        {
            var wrapper = new CatWebserviceWrapper(Service);
            PriceWebsiteDescription price = TestHelper.GetPriceWebsiteDescription();

            wrapper.Connect();

            IWebserviceResult webserviceResult = wrapper.WritePrice(price);

            Assert.IsFalse(webserviceResult.HasErrors);
            Assert.IsNotNull(webserviceResult.RequestInfo);
        }
        public void DeleteAllEventsForExistingValor()
        {
            var wrapper = new CatWebserviceWrapper(Service);
            IWebserviceResult connect = wrapper.Connect();

            Assert.IsFalse(connect.HasErrors, connect.ServiceMessage);
            Assert.IsTrue(wrapper.IsConnected);

            IWebserviceResult deleteEvents = wrapper.DeleteEvents(Settings.Default.TestProductValor);

            Assert.IsFalse(deleteEvents.HasErrors);
        }
        public void DeleteAllPricesForValor()
        {
            PriceWebsiteDescription price = TestHelper.GetPriceWebsiteDescription();

            var wrapper = new CatWebserviceWrapper(Service);

            wrapper.Connect();

            IWebserviceResult webserviceResult = wrapper.WritePrice(price);

            Assert.IsFalse(webserviceResult.HasErrors, webserviceResult.ServiceMessage);
            wrapper.DeleteAllPrices(price.Valor);
        }
        public void WriteAllBarriersForNonExistingValor()
        {
            List <BarrierWebsiteDescription> descriptions = TestHelper.GetBarrierWebsiteDescriptions();

            Assert.AreNotEqual(0, descriptions.Count());

            var wrapper = new CatWebserviceWrapper(Service);
            IWebserviceResult connect = wrapper.Connect();

            Assert.IsFalse(connect.HasErrors, connect.ServiceMessage);
            Assert.IsTrue(wrapper.IsConnected);

            IWebserviceResult writeBarriers = wrapper.WriteBarriers(Settings.Default.InvalidValor, descriptions);

            Assert.IsFalse(writeBarriers.HasErrors, writeBarriers.ServiceMessage);
        }
        public void PublishUnpublishProductWithReadData()
        {
            ProductWebsiteDescription description = TestHelper.GetProductWebsiteDescription();

            var wrapper = new CatWebserviceWrapper(Service);

            wrapper.Connect();

            IWebserviceResult writeProduct = wrapper.WriteProduct(description);

            Assert.IsFalse(writeProduct.HasErrors);

            IWebserviceResult deleteProduct = wrapper.DeleteProduct(description.Valor);

            Assert.IsFalse(deleteProduct.HasErrors);
        }
        public static void Cleanup()
        {
            if (!Settings.Default.CleanupAfterTestrun)
            {
                return;
            }

            var wrapper = new CatWebserviceWrapper(Service);

            wrapper.Connect();

            while (!wrapper.DeleteProduct(Settings.Default.TestProductValor).HasErrors)
            {
            }

            wrapper.Disconnect();
        }
        public void SyncConnectDisconnectTest()
        {
            var wrapper = new CatWebserviceWrapper(Service);

            Assert.AreEqual(WebserviceWrapperState.Disconnected, wrapper.WebserviceState);

            IWebserviceResult connect = wrapper.Connect();

            Assert.AreEqual(WebserviceWrapperState.Connected, wrapper.WebserviceState);
            Assert.IsFalse(connect.HasErrors);
            Assert.IsTrue(wrapper.IsConnected);

            IWebserviceResult disconnect = wrapper.Disconnect();

            Assert.AreEqual(WebserviceWrapperState.Disconnected, wrapper.WebserviceState);
            Assert.IsFalse(disconnect.HasErrors);
            Assert.IsFalse(wrapper.IsConnected);
        }
        public void AsyncWebserviceResultExceptionTest()
        {
            var  wrapper = new CatWebserviceWrapper(Service);
            bool wait    = true;

            wrapper.WritePriceAsync(
                TestHelper.GetPriceWebsiteDescription(),
                asyncResult =>
            {
                Assert.IsTrue(asyncResult.HasErrors);
                Assert.IsNotNull(asyncResult.ServiceMessage, asyncResult.ServiceMessage);
                wait = false;
            });

            while (wait)
            {
                Thread.Sleep(200);
            }
        }
        public void WriteAllEventsForExistingValor()
        {
            List <EventWebsiteDescription> descriptions = TestHelper.GetEventWebsiteDescriptions();

            Assert.AreNotEqual(0, descriptions.Count());

            var wrapper = new CatWebserviceWrapper(Service);
            IWebserviceResult connect = wrapper.Connect();

            Assert.IsFalse(connect.HasErrors, connect.ServiceMessage);
            Assert.IsTrue(wrapper.IsConnected);

            IWebserviceResult writeProduct = wrapper.WriteProduct(TestHelper.GetProductWebsiteDescription());

            Assert.IsFalse(writeProduct.HasErrors);

            IWebserviceResult writeEvents = wrapper.WriteEvents(Settings.Default.TestProductValor, descriptions);

            Assert.IsFalse(writeEvents.HasErrors, writeEvents.ServiceMessage);
        }
        public void AsyncConnectDisconnectTest()
        {
            var wrapper = new CatWebserviceWrapper(Service);

            Assert.AreEqual(WebserviceWrapperState.Disconnected, wrapper.WebserviceState);
            bool waiting = true;

            wrapper.ConnectAsync(
                connect =>
            {
                Assert.AreEqual(WebserviceWrapperState.Connected, wrapper.WebserviceState);
                wrapper.DisconnectAsync(
                    disconnect =>
                {
                    Assert.AreEqual(WebserviceWrapperState.Disconnected, wrapper.WebserviceState);
                    waiting = false;
                });
            });

            while (waiting)
            {
                Thread.Sleep(200);
            }
        }