コード例 #1
0
        public async void GetAll_NonExistingMarkSessionModels_ReturnsEmptyList()
        {
            // Arrange
            var markSessionModelAsyncCursor = new Mock <IAsyncCursor <MarkSessionModel> >();
            var markSessionCollection       = new Mock <IMongoCollection <MarkSessionModel> >();

            markSessionCollection
            .Setup(m => m.FindAsync(
                       It.IsAny <FilterDefinition <MarkSessionModel> >(),
                       It.IsAny <FindOptions <MarkSessionModel, MarkSessionModel> >(),
                       It.IsAny <CancellationToken>()
                       )).ReturnsAsync(markSessionModelAsyncCursor.Object);
            var dbMongoService = new Mock <IDbMongoService>();

            dbMongoService
            .Setup(m => m.GetMarkSessionCollection())
            .Returns(markSessionCollection.Object);
            var markSessionRepository = new MarkSessionRepository(dbMongoService.Object);

            // Act
            var result = await markSessionRepository.GetAll();

            // Assert
            Assert.Empty(result);
        }
コード例 #2
0
        public async void GetAll_MarkSessionModelsExist_ReturnsMarkSessionModelList()
        {
            // Arrange
            var dbMongoService        = new DbMongoService();
            var markSessionRepository = new MarkSessionRepository(dbMongoService);

            // Act
            var result = await markSessionRepository.GetAll();

            // Assert
            Assert.NotEmpty(result);
        }