public async void Delete_MarkSessionModelWithoutDependantResources_NoExceptionThrown()
        {
            // Arrange
            var markSessionModel = MarkSessionModelDataMocks.MockMarkSessionModel();

            markSessionModel.SourceDependency   = null;
            markSessionModel.DependantResources = new List <DependantResourceModel>();
            var markSessionCollection = new Mock <IMongoCollection <MarkSessionModel> >();

            markSessionCollection
            .Setup(m => m.DeleteOneAsync(
                       It.IsAny <FilterDefinition <MarkSessionModel> >(),
                       It.IsAny <CancellationToken>()
                       )).ReturnsAsync(It.IsAny <DeleteResult>());
            var dbMongoService = new Mock <IDbMongoService>();

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

            try
            {
                // Act
                await markSessionRepository.Delete(markSessionModel);
            }
            catch (CannotDeleteMarkSessionException e)
            {
                exception = e;
            }

            // Assert
            Assert.Null(exception);
        }
Пример #2
0
        public async void Delete_MarkSessionModelExists_NoExceptionThrown()
        {
            // Arrange
            var markSessionModel = new MarkSessionModel(
                "f05725ff-7da3-4dbe-83ce-184a585f47df",
                "f05725ff-7da3-4dbe-83ce-184a585f47df",
                ResourceTypeEnum.Project,
                MarkSessionTypeEnum.ToBeDeleted
                )
            {
                Id = new ObjectId("5b07dee57aa54a0007b3db52")
            };
            var       dbMongoService        = new DbMongoService();
            var       markSessionRepository = new MarkSessionRepository(dbMongoService);
            Exception exception             = null;

            try
            {
                // Act
                await markSessionRepository.Delete(markSessionModel);
            }
            catch (Exception e)
            {
                exception = e;
            }

            // Assert
            Assert.Null(exception);
        }
        public async void Delete_MarkSessionModelWithDependantResources_ThrowsException()
        {
            // Arrange
            var       markSessionModel      = MarkSessionModelDataMocks.MockMarkSessionModel();
            var       dbMongoService        = new Mock <IDbMongoService>();
            var       markSessionRepository = new MarkSessionRepository(dbMongoService.Object);
            Exception exception             = null;

            try
            {
                // Act
                await markSessionRepository.Delete(markSessionModel);
            }
            catch (CannotDeleteMarkSessionException e)
            {
                exception = e;
            }

            // Assert
            Assert.NotNull(exception);
        }