public void Test_Customer_CRUD() { #region Arrange //Add code to create required resources #endregion Arrange ICustomerConnector connector = new CustomerConnector(); #region CREATE var newCustomer = new Customer() { Name = "TestCustomer", Address1 = "TestStreet 1", Address2 = "TestStreet 2", ZipCode = "01010", City = "Testopolis", CountryCode = "SE", //CountryCode needs to be valid Email = "*****@*****.**", Type = CustomerType.Private, Active = false }; var createdCustomer = connector.Create(newCustomer); MyAssert.HasNoError(connector); Assert.AreEqual("TestCustomer", createdCustomer.Name); #endregion CREATE #region UPDATE createdCustomer.Name = "UpdatedTestCustomer"; var updatedCustomer = connector.Update(createdCustomer); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedTestCustomer", updatedCustomer.Name); #endregion UPDATE #region READ / GET var retrievedCustomer = connector.Get(createdCustomer.CustomerNumber); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedTestCustomer", retrievedCustomer.Name); #endregion READ / GET #region DELETE connector.Delete(createdCustomer.CustomerNumber); MyAssert.HasNoError(connector); retrievedCustomer = connector.Get(createdCustomer.CustomerNumber); Assert.AreEqual(null, retrievedCustomer, "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources //Add code to delete temporary resources #endregion Delete arranged resources }
public void Test_Issue95_fixed() //Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/95 { //Arrange //Creates a customer with ElectronicInvoice option for deliviery type var connector = new CustomerConnector(); var tmpCustomer = connector.Create(new Customer() { Name = "TestCustomer", DefaultDeliveryTypes = new DefaultDeliveryTypes() { Invoice = DefaultDeliveryType.ElectronicInvoice } }); MyAssert.HasNoError(connector); //Act && Assert var customer = connector.Get(tmpCustomer.CustomerNumber); MyAssert.HasNoError(connector); Assert.AreEqual(DefaultDeliveryType.ElectronicInvoice, customer.DefaultDeliveryTypes.Invoice); //Clean connector.Delete(tmpCustomer.CustomerNumber); MyAssert.HasNoError(connector); }
public void TestCustomer() { var connector = new CustomerConnector(); connector.AccessToken = at; connector.ClientSecret = cs; var customer = connector.Get("0022"); customer.GLN = "123"; customer.GLNDelivery = "12345"; customer.Active = "false"; customer = connector.Update(customer); Assert.IsFalse(connector.HasError); Assert.IsTrue(customer.Active == "false"); connector.FilterBy = Filter.Customer.Inactive; var customers = connector.Find(); Assert.IsFalse(connector.HasError); Assert.IsTrue(customers.TotalResources == "1"); customer.Active = "true"; connector.Update(customer); Assert.IsFalse(connector.HasError); Assert.IsTrue(customer.Active == "true"); }
public void TestCustomer() { var connector = new CustomerConnector(); connector.Authorization = new StaticTokenAuth(at, cs); var customer = connector.Get("0022"); customer.GLN = "123"; customer.GLNDelivery = "12345"; customer.Active = "false"; customer = connector.Update(customer); Assert.IsFalse(connector.HasError); Assert.IsTrue(customer.Active == "false"); connector.FilterBy = Filter.Customer.Inactive; var customers = connector.Find(); Assert.IsFalse(connector.HasError); Assert.IsTrue(customers.CustomerSubset.Any(c => c.CustomerNumber == "0022")); customer.Active = "true"; connector.Update(customer); Assert.IsFalse(connector.HasError); Assert.IsTrue(customer.Active == "true"); customers = connector.Find(); Assert.IsFalse(customers.CustomerSubset.Any(c => c.CustomerNumber == "0022")); }
public void TestConnection2() { var connector = new CustomerConnector(); connector.AccessToken = at; connector.ClientSecret = cs; var customer = connector.Get("0022"); Assert.IsFalse(connector.HasError); Assert.IsTrue(customer.CustomerNumber == "0022"); ConnectionCredentials.AccessToken = at; ConnectionCredentials.ClientSecret = cs; connector.AccessToken = ""; connector.ClientSecret = ""; customer = connector.Get("0022"); Assert.IsFalse(connector.HasError); Assert.IsTrue(customer.CustomerNumber == "0022"); }