public void ThrowFormatExcpetion_WhenPassedNonIntegerSecondPrice()
        {
            // Arrange
            var sessionMock = new Mock <IUserSession>();
            var user        = new User()
            {
                UserType = UserType.Admin
            };

            sessionMock.Setup(s => s.CurrentUser).Returns(user);
            var carServiceMock = new Mock <ICarService>();

            var sut        = new FilterByPriceCommand(sessionMock.Object, carServiceMock.Object);
            var parameters = new string[2] {
                "1000", "string"
            };

            // Act && Assert
            Assert.ThrowsException <FormatException>(() => sut.Execute(parameters));
        }
        public void ThrowArgumentException_WhenPassedInvalidParametersCount()
        {
            // Arrange
            var sessionMock = new Mock <IUserSession>();
            var user        = new User()
            {
                UserType = UserType.Admin
            };

            sessionMock.Setup(s => s.CurrentUser).Returns(user);
            var carServiceMock = new Mock <ICarService>();

            var sut        = new FilterByPriceCommand(sessionMock.Object, carServiceMock.Object);
            var parameters = new string[1] {
                "2000"
            };

            // Act && Assert
            Assert.ThrowsException <ArgumentException>(() => sut.Execute(parameters));
        }
        public void ReturnNoCarsMessage_WhenThereAreNoCarsInThatRange()
        {
            // Arrange
            var sessionMock = new Mock <IUserSession>();

            var user = new User()
            {
                UserType = UserType.Admin
            };

            sessionMock.Setup(s => s.CurrentUser).Returns(user);

            var carServiceMock = new Mock <ICarService>();

            var sut = new FilterByPriceCommand(sessionMock.Object, carServiceMock.Object);

            var brand = new Brand()
            {
                Name = "brand"
            };
            var bodyType = new BodyType()
            {
                Name = "bodyType"
            };
            var colorType = new ColorType()
            {
                Name = "colorType"
            };
            var color = new Color()
            {
                Name = "color", ColorType = colorType
            };
            var fuel = new FuelType()
            {
                Name = "fuel"
            };
            var gearType = new GearType()
            {
                Name = "gearType"
            };
            var gearbox = new Gearbox()
            {
                GearType = gearType
            };

            var car = new Car()
            {
                Brand    = brand,
                BodyType = bodyType,
                Color    = color,
                FuelType = fuel,
                GearBox  = gearbox,
                Price    = 3000
            };
            var cars = new List <Car>()
            {
                car
            };

            carServiceMock.Setup(c => c.GetCars(It.IsAny <string>())).Returns(cars);
            var parameters = new string[2] {
                "1000", "2000"
            };

            // Act
            var result = sut.Execute(parameters);

            // Assert
            StringAssert.Contains(result, "no cars");
        }