Ejemplo n.º 1
0
        public async Task GetAllCustomers()
        {
            var expected = new List <Customer>()
            {
                new Customer()
                {
                    ID = Guid.NewGuid(), FirstName = "Bob", Surname = "Bobby", EMail = "*****@*****.**", CustomerPassword = "******"
                },
                new Customer()
                {
                    ID = Guid.NewGuid(), FirstName = "Bob", Surname = "Bobby", EMail = "*****@*****.**", CustomerPassword = "******"
                }
            };

            var fakeRepo = new FakeCustomerRepository();

            fakeRepo.GetAllCustomersData = expected;
            var customerService = new CustomerService(fakeRepo);

            var result = await customerService.getAllCustomers();

            Assert.NotNull(result);

            Assert.Equal(2, result.Count());
            Assert.Equal(expected, result);
        }
Ejemplo n.º 2
0
        public async Task GetCustomerByID()
        {
            var id       = Guid.NewGuid();
            var expected = new Customer()
            {
                ID = id, FirstName = "Bob", Surname = "Bobby", EMail = "*****@*****.**", CustomerPassword = "******"
            };

            var fakeRepo = new FakeCustomerRepository();

            fakeRepo.GetCustomerByIDData = expected;
            var customerService = new CustomerService(fakeRepo);

            var result = await customerService.GetCustomerByID(id);

            Assert.NotNull(result);
            Assert.Equal(expected.ID, result.ID);
            Assert.Equal(expected.FirstName, result.FirstName);
        }
Ejemplo n.º 3
0
        public async Task DeleteCustomer()
        {
            var id = Guid.NewGuid();

            var customerToBeDeleted = new Customer()
            {
                ID               = id,
                FirstName        = "Bob",
                Surname          = "Bobby",
                EMail            = "*****@*****.**",
                CustomerPassword = "******"
            };
            var fakeRepo        = new FakeCustomerRepository();
            var customerService = new CustomerService(fakeRepo);

            var result = await customerService.DeleteCustomer(id);

            Assert.Equal(id, fakeRepo.DeletedCustomerId);
        }
Ejemplo n.º 4
0
        public async Task UpdateCustomer()
        {
            var id = Guid.NewGuid();
            var updatedCustomer = new UpdateCustomerRequest()
            {
                FirstName        = "Bob",
                Surname          = "Bobby",
                EMail            = "*****@*****.**",
                CustomerPassword = "******"
            };
            var fakeRepo        = new FakeCustomerRepository();
            var customerService = new CustomerService(fakeRepo);

            var result = await customerService.UpdateCustomer(updatedCustomer, id);

            Assert.NotNull(result);
            Assert.Equal(id, result.ID);
            Assert.Equal(updatedCustomer.FirstName, result.FirstName);
            Assert.NotNull(fakeRepo.UpdatedCustomer);
            Assert.Equal(id, fakeRepo.UpdatedCustomer.ID);
            Assert.Equal(updatedCustomer.FirstName, fakeRepo.UpdatedCustomer.FirstName);
        }