Esempio n. 1
0
        public async Task ApproveAsyncShould_ReturnsTrue_IfManagerRegionIsEqualToIssueRegion_OrManagerIsForAllRegionsAnd_SetsIssuePropertyIsApprovedToTrue()
        {
            //Arrange
            var manager = UserCreator.Create(RegionType.Western);
            await Db.AddAsync(manager);

            var issue = UrbanIssueCreator.CreateIssue(RegionType.Western, DefaultImageId);
            await Db.AddAsync(issue);

            await Db.SaveChangesAsync();

            var activityService = new Mock <IManagerActivityService>();

            var service = new ManagerIssueService(Db, null, activityService.Object);

            //Act
            var result = await service.ApproveAsync(manager, issue.Id);

            var dbEntryIsApproved = this.Db.UrbanIssues.FirstOrDefault(i => i.Id == issue.Id)?.IsApproved;

            //Assert
            result.Should().BeTrue();

            dbEntryIsApproved.Should().BeTrue();

            activityService.Verify(a =>
                                   a.WriteLogAsync(It.IsAny <string>(), It.IsAny <ManagerActivityType>()), Times.Once);
        }
Esempio n. 2
0
        public async Task ApproveAsyncShould_ReturnsFalse_IfManagerRegionIsNotEqualToIssueRegion()
        {
            //Arrange
            var activityService = new Mock <IManagerActivityService>();

            var service = new ManagerIssueService(Db, null, activityService.Object);

            var manager = UserCreator.Create(RegionType.Central);
            await Db.AddAsync(manager);

            var issue = UrbanIssueCreator.CreateIssue(RegionType.Western);
            await Db.AddAsync(issue);

            await Db.SaveChangesAsync();

            //Act
            var result = await service.ApproveAsync(manager, issue.Id);

            //Assert
            result.Should().BeFalse();

            activityService.Verify(a => a.WriteLogAsync(It.IsAny <string>(), It.IsAny <ManagerActivityType>()), Times.Never);
        }