Ejemplo n.º 1
0
            public async Task UpdateCustomer()
            {
                // Arrange
                Customer customer = new Customer {
                    Name = "Test3", AddressLn1 = "Test Address 2", Phone = "111111", Vehicles = new Vehicle[] { new Vehicle {
                                                                                                                    RegNo = "TestRegNo3", VIN = "TestVIN 3"
                                                                                                                } }
                };

                await AddCustomer(customer);

                // Act
                customer.AddressLn1 = "Test Address 3"; customer.AddressLn2 = "Test Address 4"; customer.AddressLn3 = "Test Address 5"; customer.Phone = "12121212";
                var result = await Client.PutAsync("customers/" + customer.Id, new StringContent(JsonConvert.SerializeObject(customer), Encoding.Unicode, "application/json"));

                // Assert
                result.EnsureSuccessStatusCode();
                var updatedCustomer = await GetCustomerByName(customer.Name);

                Assert.True(EqualityHelper.SameCustomers(customer, updatedCustomer));

                // Purge
                result = await Client.DeleteAsync(baseController + "/" + updatedCustomer.Id);

                result.EnsureSuccessStatusCode();
            }
Ejemplo n.º 2
0
            public async void GetById()
            {
                // Arrange
                var expectedCustomer = customers[2];

                CustomersRepositoryMock
                .Setup(x => x.GetAsync(3))
                .ReturnsAsync(expectedCustomer);

                // Act
                var result = await ServiceUnderTest.GetAsync(3);

                // Assert
                Assert.True(EqualityHelper.SameCustomers(expectedCustomer, result));
            }
Ejemplo n.º 3
0
            public async Task AddCustomer()
            {
                // Arrange
                Customer customer = new Customer {
                    Name = "Test1", AddressLn1 = "Test Address", Phone = "123456789", Vehicles = new Vehicle[] { new Vehicle {
                                                                                                                     RegNo = "TestRegNo1", VIN = "TestVIN1"
                                                                                                                 } }
                };

                // Act
                var result = await Client.PostAsync(baseController, new StringContent(JsonConvert.SerializeObject(customer), Encoding.Unicode, "application/json"));

                // Assert
                result.EnsureSuccessStatusCode();
                var addedCustomer = await GetCustomerByName(customer.Name);

                customer.Id = addedCustomer.Id;
                Assert.True(EqualityHelper.SameCustomers(customer, addedCustomer));

                // Purge
                result = await Client.DeleteAsync(baseController + "/" + addedCustomer.Id);

                result.EnsureSuccessStatusCode();
            }