コード例 #1
0
        public async void GetById_ShouldReturnVenue_NotFound(
            [Frozen] Mock <IRepository <Guid, Venue> > repository
            , Guid venueId
            , VenueQueryService svc)
        {
            // ARRANGE
            repository.Setup(r => r.FindByIdAsync(It.IsAny <Guid>(), It.IsAny <bool>()))
            .ReturnsAsync((Venue)null);

            // ACT
            var venue = await svc.GetByIdAsync(venueId);

            // ARRANGE
            Assert.Null(venue);
        }
コード例 #2
0
        public async void GetById_ShouldReturnVenue_Found(
            [Frozen] Mock <IRepository <Guid, Venue> > repository
            , Guid venueId
            , VenueQueryService svc)
        {
            // ARRANGE
            repository.Setup(r => r.FindByIdAsync(It.IsAny <Guid>(), It.IsAny <bool>()))
            .ReturnsAsync(new Venue("Test"));

            // ACT
            var venue = await svc.GetByIdAsync(venueId);

            // ARRANGE
            Assert.Equal("Test", venue.Name);
            Assert.Null(venue.Address);
        }
コード例 #3
0
        public async void GetAllSync_ShouldCallRepository(
            [Frozen] Mock <IRepository <Guid, Venue> > repository
            , VenueQueryService svc)
        {
            // ARRANGE
            repository.Setup(r => r.ListAsync())
            .ReturnsAsync(new [] { new Venue("Test") });

            // ACT
            var venues = await svc.GetAllAsync();

            // ASSERT
            Assert.Single(venues);
            Assert.Equal("Test", venues.First().Name);
            Assert.Null(venues.First().Address);
        }
コード例 #4
0
 public async void GetById_ShouldThrowException_WhenVenueIdIsEmpty(
     VenueQueryService svc)
 {
     // ACT
     await Assert.ThrowsAsync <ArgumentNullException>(() => svc.GetByIdAsync(Guid.Empty));
 }