Exemple #1
0
        public void Update_BadTrip_ThrowException()
        {
            //Arrange
            IList <Trip> trips = new List <Trip>()
            {
                new Trip()
                {
                    Id = 1, ClientName = "Gigi"
                },
                new Trip()
                {
                    Id = 2
                }
            };

            Mock <ITripRepository> MockTripRepository = new Mock <ITripRepository>();

            TripRepositorySetupMoq.Update(MockTripRepository, trips);
            TripRepositorySetupMoq.GetAll(MockTripRepository, trips);
            ITripRepository tripRepository = MockTripRepository.Object;

            //Act
            Trip trip = new Trip()
            {
                Id = 3, ClientName = "Alin"
            };

            //Assert
            Trip result = tripRepository.Update(trip);
        }
Exemple #2
0
        public void Update_GoodTrip_UpdateTrip()
        {
            //Arrange
            IList <Trip> trips = new List <Trip>()
            {
                new Trip()
                {
                    Id = 1, ClientName = "Gigi"
                },
                new Trip()
                {
                    Id = 2
                }
            };

            Mock <ITripRepository> MockTripRepository = new Mock <ITripRepository>();

            TripRepositorySetupMoq.Update(MockTripRepository, trips);
            TripRepositorySetupMoq.GetAll(MockTripRepository, trips);
            ITripRepository tripRepository = MockTripRepository.Object;

            //Act
            Trip trip = new Trip()
            {
                Id = 1, ClientName = "Alin"
            };
            Trip         result      = tripRepository.Update(trip);
            IList <Trip> findedTrips = tripRepository.GetAll();

            //Assert
            Assert.AreEqual(result, trip);
            Assert.AreEqual(findedTrips.Count, trips.Count);
            Assert.AreEqual(findedTrips[1], trips[1]);
            Assert.AreEqual(trips[1], trip);
        }
Exemple #3
0
        public void FindAll_ReturnsList()
        {
            //Arrange
            IList <Trip> trips = new List <Trip>()
            {
                new Trip(),
                new Trip()
            };

            Mock <ITripRepository> MockTripRepository = new Mock <ITripRepository>();

            TripRepositorySetupMoq.GetAll(MockTripRepository, trips);
            ITripRepository tripRepository = MockTripRepository.Object;

            //Act
            IList <Trip> findedTrips = tripRepository.GetAll();

            //Assert
            Assert.AreEqual(findedTrips.Count, trips.Count);
        }
Exemple #4
0
        public void Add_Any_Modify()
        {
            //Arrange
            IList <Trip> trips = new List <Trip>();

            Mock <ITripRepository> MockTripRepository = new Mock <ITripRepository>();

            TripRepositorySetupMoq.Add(MockTripRepository, trips);
            TripRepositorySetupMoq.GetAll(MockTripRepository, trips);
            ITripRepository tripRepository = MockTripRepository.Object;

            //Act
            Trip         trip        = new Trip();
            Trip         result      = tripRepository.Add(trip);
            IList <Trip> findedTrips = tripRepository.GetAll();

            //Assert
            Assert.AreEqual(result, trip);
            Assert.AreEqual(findedTrips.Count, trips.Count);
        }