Exemplo n.º 1
0
        public async Task Post_NormalParameters_Sucess()
        {
            CreatingTripDto creatingTripDto = new CreatingTripDto("asdsds", "asfdsa", "dcxvxc", new int[] { 1, 2, 3, 4, 5 });

            TripDto tripDto        = TripMapper.toDTO(creatingTripDto);
            Trip    trip           = TripMapper.toDomain(tripDto);
            var     mockRepository = new Mock <ITripRepository>();

            mockRepository.Setup(repository => repository.AddAsync(It.IsAny <Trip>())).Returns(Task.FromResult(trip));

            var mockUnit = new Mock <IUnitOfWork>();

            TripService     TripService = new TripService(mockUnit.Object, mockRepository.Object);
            TripsController controller  = new TripsController(TripService);

            var result = await controller.Create(creatingTripDto);

            mockRepository.Verify(repository => repository.AddAsync(It.IsAny <Trip>()), Times.AtLeastOnce());
            mockUnit.Verify(unit => unit.CommitAsync(), Times.AtLeastOnce());
            Assert.IsInstanceOfType(result, typeof(ActionResult <TripDto>));
        }
Exemplo n.º 2
0
        public void testToDomain()
        {
            string key  = "keyTrip1";
            string line = "lineTest1";
            string path = "pathTest1";

            int[]      passingTimes  = { 1, 2, 3, 4, 5 };
            List <int> lPassingTimes = new List <int>();

            lPassingTimes.AddRange(passingTimes);

            Trip t          = new Trip(key, line, path, lPassingTimes);
            Trip mapperTrip = TripMapper.toDomain(TripMapper.toDTO(new CreatingTripDto(key, line, path, passingTimes)));

            Assert.AreEqual(t.Key, mapperTrip.Key);
            Assert.AreEqual(t.Line, mapperTrip.Line);
            Assert.AreEqual(t.Path, mapperTrip.Path);
            foreach (PassingTime pt in mapperTrip.PassingTimes)
            {
                Assert.IsNotNull(t.PassingTimes.Contains(pt));
            }
        }