コード例 #1
0
        public async Task GetTutorialById_WithInValidId_ShouldThrow()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act

            //Assert
            await Assert.ThrowsAsync <NullReferenceException>(async() => await service.GetTutorialById(3));
        }
コード例 #2
0
        public async Task GetTutorialById_WithValidId_ShouldReturnModel()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act
            var model = await service.GetTutorialById(2);

            var expectedId = 2;
            var actualId   = model.Id;

            //Assert
            Assert.NotNull(model);
            Assert.Equal(expectedId, actualId);
        }