public void GetCarMarks_Must_Return_All_Car_Marks()
        {
            //Arrange

            var marks = new List <CarMark>
            {
                CarMarksUtils.Create(1, "Aaaa"),
                CarMarksUtils.Create(2, "Bbbb"),
                CarMarksUtils.Create(3, "Cccc", true),
                CarMarksUtils.Create(4, "Dddd", true),
                CarMarksUtils.Create(5, "Eeee")
            };

            var repository = new Mock <ICarMarksRepository>();

            repository.Setup(act => act.GetAll(true)).Returns(marks.AsQueryable());
            _unitOfWorkMock.Setup(act => act.Repository <ICarMarksRepository>()).Returns(repository.Object);

            //Act
            var result = _manager.GetCarMarks(null);

            //Assert
            Assert.AreEqual(3, result.Count());
            Assert.AreEqual(marks[0].Name, result.ElementAt(0).Name);
            Assert.AreEqual(marks[1].Name, result.ElementAt(1).Name);
            Assert.AreEqual(marks[4].Name, result.ElementAt(2).Name);
        }
        public void GetCarMarks_Must_Return_All_Car_Marks_Witch_Contains_SearhText()
        {
            //Arrange

            var searchText = "Aa";
            var marks      = new List <CarMark>
            {
                CarMarksUtils.Create(1, "Aaaa"),
                CarMarksUtils.Create(2, "Bbbb"),
                CarMarksUtils.Create(3, "Aacc", true),
                CarMarksUtils.Create(4, "DdAa", true),
                CarMarksUtils.Create(5, "Aaee"),
                CarMarksUtils.Create(6, "FfAa"),
                CarMarksUtils.Create(7, "GgAaHh")
            };

            var repository = new Mock <ICarMarksRepository>();

            repository.Setup(act => act.GetAll(true)).Returns(marks.AsQueryable());
            _unitOfWorkMock.Setup(act => act.Repository <ICarMarksRepository>()).Returns(repository.Object);

            //Act
            var result = _manager.GetCarMarks(searchText);

            //Assert
            Assert.AreEqual(4, result.Count());
            Assert.AreEqual(marks[0].Name, result.ElementAt(0).Name);
            Assert.AreEqual(marks[4].Name, result.ElementAt(1).Name);
            Assert.AreEqual(marks[5].Name, result.ElementAt(2).Name);
            Assert.AreEqual(marks[6].Name, result.ElementAt(3).Name);
        }
        public void GetModels_Must_Returns_All_Models_For_A_Certain_Mark_Without_Errors()
        {
            //Arrange
            var mark = CarMarksUtils.Create(1, "test");

            mark.Models = new List <CarModel>
            {
                CarModelUtils.Create(0, "Aaaa"),
                CarModelUtils.Create(1, "Bbbb"),
                CarModelUtils.Create(2, "Cccc", true),
                CarModelUtils.Create(3, "Dddd"),
                CarModelUtils.Create(4, "Eeee", true)
            };

            var markRepository = new Mock <ICarMarksRepository>();

            markRepository.Setup(act => act.Get(mark.Id)).Returns(mark);
            _unitOfWorkMock.Setup(act => act.Repository <ICarMarksRepository>()).Returns(markRepository.Object);

            //Act
            IEnumerable <CarModelDto> result = null;

            Assert.DoesNotThrow(() => result = _manager.GetModels(mark.Id));

            //Assert
            Assert.NotNull(result);
            Assert.AreEqual(3, result.Count());
            Assert.AreEqual(mark.Models.ElementAt(0).Name, result.ElementAt(0).Name);
            Assert.AreEqual(mark.Models.ElementAt(1).Name, result.ElementAt(1).Name);
            Assert.AreEqual(mark.Models.ElementAt(3).Name, result.ElementAt(2).Name);
        }