Beispiel #1
0
        public void ReturnTrue_WhenParamsAreValid()
        {
            // Arrange
            var contextMock = new Mock <ITravelGuideContext>();
            var factoryMock = new Mock <IStoreItemFactory>();

            var service = new StoreService(contextMock.Object, factoryMock.Object);

            var itemName       = "itemName";
            var description    = "description";
            var destinationFor = "Iliolousti Ellada";
            var imageUrl       = "url";
            var brand          = "brand";
            var price          = "10";

            factoryMock.Setup(x => x.CreateStoreItem(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(),
                                                     It.IsAny <string>(), It.IsAny <double>()));
            contextMock.Setup(x => x.StoreItems.Add(It.IsAny <StoreItem>()));

            // Act
            var isSuccessful = service.AddNewItem(itemName, description, destinationFor, imageUrl, brand, price);

            // Assert
            Assert.IsTrue(isSuccessful);
        }
Beispiel #2
0
        public void ThrowNullArgumentException_WhenPassedBrandIsNull()
        {
            // Arrange
            var contextMock = new Mock <ITravelGuideContext>();
            var factoryMock = new Mock <IStoreItemFactory>();

            var service = new StoreService(contextMock.Object, factoryMock.Object);

            var itemName       = "itemName";
            var description    = "description";
            var destinationFor = "Iliolousti Ellada";
            var imageUrl       = "url";
            var price          = "10";

            // Act
            Assert.Throws <ArgumentNullException>(() => service.AddNewItem(itemName, description, destinationFor, imageUrl, null, price));
        }
Beispiel #3
0
        public void ReturnFalse_WhenPassedPriceIsNotParsableToDouble()
        {
            // Arrange
            var contextMock = new Mock <ITravelGuideContext>();
            var factoryMock = new Mock <IStoreItemFactory>();

            var service = new StoreService(contextMock.Object, factoryMock.Object);

            var itemName       = "itemName";
            var description    = "description";
            var destinationFor = "Iliolousti Ellada";
            var imageUrl       = "url";
            var brand          = "brand";
            var price          = "asdas";

            // Act
            var isParsed = service.AddNewItem(itemName, description, destinationFor, imageUrl, brand, price);

            // Assert
            Assert.IsFalse(isParsed);
        }