public void GetSortedByTitle()
        {
            // Arrange
            CarAdvertController controller = new CarAdvertController();

            controller.DummyAdvertList = TestAdvertList.ToList();
            // Act
            IEnumerable <CarAdvertViewModel> result = controller.GetAll("title");

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(TestAdvertList.ElementAtOrDefault(4), result.ElementAt(0));
            Assert.AreEqual(TestAdvertList.ElementAtOrDefault(0), result.ElementAt(1));
        }
        public void Get()
        {
            // Arrange
            CarAdvertController controller = new CarAdvertController();

            controller.DummyAdvertList = TestAdvertList.ToList();
            // Act
            IEnumerable <CarAdvertViewModel> result = controller.GetAll();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(6, result.Count());
            Assert.AreEqual(TestAdvertList.FirstOrDefault(), result.ElementAt(0));
            Assert.AreEqual(TestAdvertList.LastOrDefault(), result.ElementAt(5));
        }
        public void Put()
        {
            // Arrange
            CarAdvertController controller = new CarAdvertController();

            controller.DummyAdvertList = TestAdvertList.ToList();
            // Act
            CarAdvertViewModel putAdvert = new CarAdvertViewModel(5);

            controller.PutAdvert(5, putAdvert);
            IEnumerable <CarAdvertViewModel> result = controller.GetAll();

            // Assert
            Assert.AreEqual(6, result.Count());
            Assert.AreEqual(putAdvert.Title, result.ElementAt(4).Title);
        }
        public void Delete()
        {
            // Arrange
            CarAdvertController controller = new CarAdvertController();

            controller.DummyAdvertList = TestAdvertList.ToList();
            // Act
            CarAdvertViewModel oldAdvertOne = controller.GetAdvertById(1);
            CarAdvertViewModel oldAdvertTwo = controller.GetAdvertById(2);

            controller.DeleteAdvert(1);
            IEnumerable <CarAdvertViewModel> result = controller.GetAll();

            // Assert
            Assert.AreEqual(5, result.Count());
            Assert.AreNotEqual(oldAdvertOne, result.ElementAt(0));
            Assert.AreEqual(oldAdvertTwo, result.ElementAt(0));
        }