public async Task AllMapInfoDetailsAsync(bool isApprovedParam, RegionType regionParam)
        {
            //Arrange
            var service = new IssueService(this.db);

            var user = this.CreateUser();

            await this.db.AddAsync(user);

            var image = this.CreateImage(user.Id);

            await this.db.AddRangeAsync(image);

            var issue            = this.CreateIssue(true, user.Id, regionParam);
            var notApprovedIssue = this.CreateIssue(false, user.Id, regionParam);

            await this.db.AddRangeAsync(issue, notApprovedIssue);

            await this.db.SaveChangesAsync();

            //Act
            var resultModel = await service.AllMapInfoDetailsAsync(isApprovedParam, regionParam);

            var expected = this.db.UrbanIssues
                           .Where(i => i.IsApproved == isApprovedParam && i.Region == regionParam)
                           .To <IssueMapInfoBoxDetailsServiceModel>();

            //Assert
            resultModel.Should().AllBeOfType <IssueMapInfoBoxDetailsServiceModel>();
            resultModel.Should().BeEquivalentTo(expected);
        }
Example #2
0
        public async Task AllMapInfoDetailsAsync(bool isApprovedParam, RegionType regionParam)
        {
            //Arrange
            var user = UserCreator.Create();

            await this.Db.AddAsync(user);

            var image = ImageInfoCreator.CreateWithFullData(user.Id);

            await this.Db.AddRangeAsync(image);

            var issue             = CreateIssue(true, RegionType.All, user.Id, image.Id);
            var secondIssue       = CreateIssue(true, RegionType.Thracia, user.Id, image.Id);
            var thirdIssue        = CreateIssue(true, RegionType.Western, user.Id, image.Id);
            var notApprovedIssue  = CreateIssue(false, RegionType.Western, user.Id, image.Id);
            var secondNotApproved = CreateIssue(false, RegionType.Eastern, user.Id, image.Id);

            await this.Db.AddRangeAsync(issue, secondIssue, thirdIssue, notApprovedIssue, secondNotApproved);

            await this.Db.SaveChangesAsync();

            //TODO: rearrange test - now issueService has more parameters
            var service = new IssueService(this.Db, null);

            //Act
            var resultModel = (await service.AllMapInfoDetailsAsync <IssueMapInfoBoxModel>(isApprovedParam, regionParam)).ToList();

            var issuesToNotContain = this.Db.UrbanIssues.Where(i => i.IsApproved != isApprovedParam);

            var notContainFromAnotherRegions = this.Db.UrbanIssues.Where(i => i.Region != regionParam);

            //Assert
            resultModel.Should().AllBeOfType <IssueMapInfoBoxModel>();

            resultModel.Should().NotContain(issuesToNotContain);

            if (regionParam != RegionType.All)
            {
                resultModel.Should().NotContain(notContainFromAnotherRegions);
            }
        }