public void CreateAuthor_ShouldCreateValidAuthor()
        {
            // Fixture setup
            var authorRepo    = new InMemoryRepository <Author>();
            var authorService = new AuthorApplicationService(authorRepo);

            var expected = new Author()
            {
                FirstName = "blah",
                LastName  = "fdlskhgdsa",
                Synopsis  = "fhlkhdfaslkhjgoiuwer"
            };

            // Exercise the SUT (system under test)
            authorService.CreateAuthor(
                expected.FirstName,
                expected.LastName,
                expected.Synopsis);

            // State verification
            var actual = authorRepo.AsQueryable().FirstOrDefault();

            Assert.Equal(1, authorRepo.Count());
            Assert.Equal(expected.FirstName, actual.FirstName);
            Assert.Equal(expected.LastName, actual.LastName);
            Assert.Equal(expected.Synopsis, actual.Synopsis);
        }
        public void CreateProduct_ShouldCreateValidProduct()
        {
            var productRepo    = new InMemoryRepository <Product>();
            var productService = new ProductService(productRepo);


            //Fixture Setup
            var expected = new Product()
            {
                CategoryId  = 1,
                ProductName = "Product test",
                Description = "this is description",
                Cost        = 12,
                Price       = 15,
                VendorId    = 1
            };

            //Exercise the SUT (system under test)

            productService.CreateProduct(expected.CategoryId, expected.ProductName, expected.Description, expected.Cost.Value,
                                         expected.Price.Value, expected.VendorId);

            // State Verification
            var actual = productRepo.AsQueryable().FirstOrDefault();

            Assert.Equal(1, productRepo.Count());
            Assert.Equal(expected.CategoryId, actual.CategoryId);
            Assert.Equal(expected.ProductName, actual.ProductName);
            Assert.Equal(expected.Description, actual.Description);
            Assert.Equal(expected.Cost, actual.Cost);
            Assert.Equal(expected.Price, actual.Price);
            Assert.Equal(expected.VendorId, actual.VendorId);
        }
예제 #3
0
        public void CreateCustomer_ShouldCreateValidCustomer()
        {
            var customerRepo    = new InMemoryRepository <Customer>();
            var customerService = new CustomerService(customerRepo);


            //Fixture Setup
            var expected = new Customer()
            {
                CustomerCode  = "1001",
                FirstName     = "Ken",
                MiddleName    = "Yew",
                LastName      = "Hang",
                DateOfBirth   = DateTime.Now,
                Gender        = "Male",
                StreetAddress = "5 Kimbery Ave",
                Suburb        = "Lane Cove",
                PostCode      = "2066",
                State         = "Sydney",
                PhoneNo       = "4325435345"
            };

            //Exercise the SUT (system under test)
            //customerService.CreateCustomer(expected.CustomerCode, expected.DateOfBirth, expected.FirstName,
            //    expected.LastName, expected.MiddleName, expected.Gender, expected.PhoneNo, expected.StreetAddress,
            //    expected.PostCode, expected.Suburb, expected.State);

            // State Verification
            var actual = customerRepo.AsQueryable().FirstOrDefault();

            Assert.Equal(1, customerRepo.Count());
            Assert.Equal(expected.FirstName, actual.FirstName);
            Assert.Equal(expected.LastName, actual.LastName);
            Assert.Equal(expected.DateOfBirth, actual.DateOfBirth);
            Assert.Equal(expected.Gender, actual.Gender);
            Assert.Equal(expected.StreetAddress, actual.StreetAddress);
            Assert.Equal(expected.Suburb, actual.Suburb);
            Assert.Equal(expected.State, actual.State);
            Assert.Equal(expected.PostCode, actual.PostCode);
            Assert.Equal(expected.PhoneNo, actual.PhoneNo);
            Assert.Equal(expected.CustomerCode, actual.CustomerCode);
        }