public void AddCallsAddFromRepository()
        {
            var testItem = ProductObjectMother.CreateAvailableProduct(1);

            ProductService.Add(testItem);
            ProductRepositoryMock.Verify(x => x.Add(testItem), Times.Once());
        }
Beispiel #2
0
        public void IsAvailableReturnsFalseWithQuantityZero()
        {
            var product = ProductObjectMother.CreateUnavailableProduct(1);

            var res = product.IsAvailable();

            Assert.IsFalse(res);
        }
Beispiel #3
0
        public void IsAvailableReturnsTrueWithPositiveQuantity()
        {
            var product = ProductObjectMother.CreateAvailableProduct(1);

            var res = product.IsAvailable();

            Assert.IsTrue(res);
        }
        public void UpdateCallsUpdateFromRepository()
        {
            var product = ProductObjectMother.CreateProductWithNoId();

            ProductService.Add(product);
            product.Name = "New name";
            ProductService.Update(product);
            ProductRepositoryMock.Verify(x => x.Update(product));
        }
Beispiel #5
0
        public void CheckAddProperty()
        {
            ShopService ss = new ShopService();

            var product  = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand();
            var property = ProductObjectMother.CreatePropertyColorWithValueBlue();

            ss.AddProperty(product, property);

            Assert.AreEqual(product.Properties.Contains(property), true);
        }
Beispiel #6
0
        public void CheckSetBrand()
        {
            ShopService ss = new ShopService();

            var product = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand();
            var brand   = ProductObjectMother.CreateBrandWithNameHoyt();

            ss.SetBrand(product, brand);

            Assert.AreEqual(product.Brand, brand);
        }
Beispiel #7
0
        public void CheckCreateCategoryMethodResult()
        {
            Category category    = ProductObjectMother.CreateCategory();
            var      transaction = _session.BeginTransaction();

            ps.CreateCategory(category);
            transaction.Commit();

            List <Category> categories = ps.GetAllCategory();

            Assert.AreEqual(1, categories.Count);
        }
Beispiel #8
0
        public void CheckCreateArtistMethodResult()
        {
            Artist artist      = ProductObjectMother.CreateArtist();
            var    transaction = _session.BeginTransaction();

            ps.CreateArtist(artist);
            transaction.Commit();

            List <Artist> artists = ps.GetAllArtists();

            Assert.AreEqual(1, artists.Count);
        }
Beispiel #9
0
        public void CheckGetArtistMethodResult()
        {
            Artist artist      = ProductObjectMother.CreateArtist();
            var    transaction = _session.BeginTransaction();

            ps.CreateArtist(artist);
            transaction.Commit();

            Artist result = ps.GetArtist(artist.Id);

            Assert.AreEqual(artist.Id, result.Id);
        }
Beispiel #10
0
        public void CheckPropertyToProduct()
        {
            // Arrange
            var product  = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand();
            var property = ProductObjectMother.CreatePropertyColorWithValueBlue(1);

            product.properties.Add(property);


            // Assert
            Assert.IsTrue(product.properties.Count == 1);
        }
Beispiel #11
0
        public void CheckSetBrandToProduct()
        {
            // Arrange
            var product = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand();
            var brand   = ProductObjectMother.CreateBrandWithNameHoyt(1);

            product.Brand = brand;


            // Assert
            Assert.IsTrue(product.Brand.Name == "Hoyt");
        }
Beispiel #12
0
        public void CheckInsertMethodCalled()
        {
            // Arrange
            Mock <IProductRepository> repositoryMock = new Mock <IProductRepository>();
            IProductService           service        = new ProductService(repositoryMock.Object);
            var product = ProductObjectMother.CreateProduct();

            // Act
            service.Insert(product);

            // Assert
            repositoryMock.Verify(k => k.Insert(product), Times.Once());
        }
Beispiel #13
0
        public void CheckAddToOrder()
        {
            ShopService ss = new ShopService();

            Product product    = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand();
            Order   order      = OrderObjectMother.CreateOrderWithNoItems();
            int     quantitity = 2;

            var orderItems = ss.AddToOrder(product, order, quantitity);

            Assert.AreEqual(orderItems.Product, product);
            Assert.AreEqual(orderItems.Quantitity, quantitity);
            Assert.AreEqual(order.OrderItems.Contains(orderItems), true);
        }
Beispiel #14
0
        public Album CreateArtistCategoryAlbum()
        {
            var transaction = _session.BeginTransaction();

            Artist   artist   = ps.CreateArtist(ProductObjectMother.CreateArtist());
            Category category = ps.CreateCategory(ProductObjectMother.CreateCategory());
            Album    album    = ProductObjectMother.CreateAlbum();

            album.Artist   = artist;
            album.Category = category;
            album          = ps.CreateAlbum(album);

            transaction.Commit();
            return(album);
        }