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 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 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);
            }
        }
        public void DeleteAllBarriersForExistingValor()
        {
            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.TestProductValor);
            Assert.IsFalse(deleteBarriers.HasErrors);
        }
        public void WriteProductWithEmptyDescription()
        {
            var wrapper = new CatWebserviceWrapper(Service);
            wrapper.Connect();

            IWebserviceResult webserviceResult = wrapper.WriteProduct(TestHelper.GetEmptyProductWebsiteDescription());
            Assert.IsTrue(webserviceResult.HasErrors, webserviceResult.ServiceMessage);
        }
        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 WriteAllEventsForNonExistingValor()
        {
            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 writeEvents = wrapper.WriteEvents(Settings.Default.InvalidValor, descriptions);
            Assert.IsFalse(writeEvents.HasErrors, writeEvents.ServiceMessage);
        }
        public void WriteAllBaseValuesForExistingValor()
        {
            List<BaseValueWebsiteDescription> descriptions = TestHelper.GetBaseValueWebsiteDescriptions();
            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 writeBaseValues = wrapper.WriteBaseValues(Settings.Default.TestProductValor, descriptions);
            Assert.IsFalse(writeBaseValues.HasErrors, writeBaseValues.ServiceMessage);
        }
        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 WebserviceResultExceptionTest()
 {
     var wrapper = new CatWebserviceWrapper(Service);
     IWebserviceResult result = wrapper.WritePrice(TestHelper.GetPriceWebsiteDescription());
     Assert.IsTrue(result.HasErrors);
     Assert.IsNotNull(result.ServiceMessage, result.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 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 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 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 DeleteAllEventsForNonExistingValor()
        {
            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.InvalidValor);
            Assert.IsTrue(deleteEvents.HasErrors);
        }