Exemple #1
0
        public async Task CreatePreRegistrationUser_CreatingUser_ReturningTrue()
        {
            _mockUserStatusRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new UserStatus {
                Id = 1
            });
            _mockShopUserRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <ShopUser, bool> > >())).ReturnsAsync(new List <ShopUser> {
                new ShopUser {
                    Id = 1
                }
            });
            _mockUnitOfWork.Setup(x => x.CommitAsync()).ReturnsAsync(true);

            var hierarchyProcesses = new HierarchyProcessesService(
                _mockSaleFileRepository.Object,
                _mockEmailService.Object,
                _mockUserAccessCodeInviteRepository.Object,
                _mockUserPunctuationSourceRepository.Object,
                _mockUserPunctuationRepository.Object,
                _mockUserStatusLogRepository.Object,
                _mockLogger.Object,
                _mockHierarchyFileDataRepository.Object,
                _mockHierarchyFileDataErrorRepository.Object,
                _mockHierarchyFileRepository.Object,
                _mockFileStatusRepository.Object,
                _mockUserRepository.Object,
                _mockUserStatusRepository.Object,
                _mockShopRepository.Object,
                _mockShopUserRepository.Object,
                _mockUnitOfWork.Object,
                _mockOfficeRepository.Object,
                _mockSaleRepository.Object);

            var hierarchyFileData = new HierarchyFileData {
                Name = "teste", Cpf = "00000000000"
            };
            var office = new Office {
                Id = 1
            };
            var shop = new Shop {
                Id = 1
            };

            var result = await hierarchyProcesses.CreatePreRegistrationUser(hierarchyFileData, office, shop);

            Assert.True(result);
        }
Exemple #2
0
        public async Task UpdateHierarchyUsers_PreRegistrationOffUserProcessing_ReturningUser()
        {
            _mockSaleRepository.Setup(x => x.CustomFindLast(It.IsAny <Expression <Func <Sale, bool> > >(), It.IsAny <Expression <Func <Sale, int> > >())).ReturnsAsync(new Sale {
                CreatedAt = DateTime.Now
            });
            _mockShopUserRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <ShopUser, bool> > >())).ReturnsAsync(new List <ShopUser> {
                new ShopUser {
                    Shop = new Shop {
                        Id = 10
                    }
                }
            });

            var arrangeStatus = new List <UserStatus>();

            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.PreRegistration
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.WaitingForEmail
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.Active
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.Off
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.Inactive
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.WaitingForSMS
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.OnlyCatalog
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.PasswordExpired
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.FriendInvitation
            });

            _mockUserStatusRepository.Setup(x => x.GetById(It.IsAny <int>()))
            .ReturnsAsync((int param) => arrangeStatus.AsQueryable().Where(x => x.Id == param).First());

            var user = new User {
                Id = 10, UserStatus = new UserStatus {
                    Id = (int)UserStatusEnum.PreRegistration
                }, Office = new Office {
                    Id = (int)OfficeEnum.Salesman
                }
            };
            var hierarchyFileData = new HierarchyFileData {
                Off = "SIM"
            };
            var office = new Office {
                Id = (int)OfficeEnum.Salesman
            };
            var shop = new Shop {
                Id = 10
            };

            var hierarchyProcesses = new HierarchyProcessesService(
                _mockSaleFileRepository.Object,
                _mockEmailService.Object,
                _mockUserAccessCodeInviteRepository.Object,
                _mockUserPunctuationSourceRepository.Object,
                _mockUserPunctuationRepository.Object,
                _mockUserStatusLogRepository.Object,
                _mockLogger.Object,
                _mockHierarchyFileDataRepository.Object,
                _mockHierarchyFileDataErrorRepository.Object,
                _mockHierarchyFileRepository.Object,
                _mockFileStatusRepository.Object,
                _mockUserRepository.Object,
                _mockUserStatusRepository.Object,
                _mockShopRepository.Object,
                _mockShopUserRepository.Object,
                _mockUnitOfWork.Object,
                _mockOfficeRepository.Object,
                _mockSaleRepository.Object);

            var result = await hierarchyProcesses.UpdateHierarchyUsers(user, hierarchyFileData, office, shop);

            Assert.Equal((int)UserStatusEnum.Inactive, result.UserStatus.Id);
        }
Exemple #3
0
        public async Task ProcessesHierarchyFile_ProcessingHierarchyRead_UpdatingUserReturningTrue()
        {
            _mockSaleFileRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <SaleFile, bool> > >(), It.IsAny <Expression <Func <SaleFile, object> > >())).ReturnsAsync(new List <SaleFile> {
                new SaleFile {
                    Id = 10, FileStatus = new FileStatus {
                        Id = 5
                    }
                }
            });
            _mockHierarchyFileRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <HierarchyFile, bool> > >(), It.IsAny <Expression <Func <HierarchyFile, object> > >(), It.IsAny <Expression <Func <HierarchyFile, object> > >())).ReturnsAsync(new List <HierarchyFile> {
                new HierarchyFile {
                    Id = 10, FileStatus = new FileStatus {
                        Id = 10
                    }
                }
            });
            _mockHierarchyFileDataRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <HierarchyFileData, bool> > >())).ReturnsAsync(new List <HierarchyFileData> {
                new HierarchyFileData {
                    Id = 10, Office = "VENDEDOR"
                }
            });
            _mockUserRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <User, bool> > >(), It.IsAny <Expression <Func <User, object> > >())).ReturnsAsync(new List <User> {
                new User {
                    Id = 10, UserStatus = new UserStatus {
                        Id = (int)UserStatusEnum.Active
                    }
                }
            });
            _mockShopRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <Shop, bool> > >())).ReturnsAsync(new List <Shop> {
                new Shop {
                    Id = 10
                }
            });
            _mockOfficeRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <Office, bool> > >())).ReturnsAsync(new List <Office> {
                new Office {
                    Id = 10
                }
            });
            _mockOfficeRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new Office {
                Id = 10
            });
            _mockFileStatusRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new FileStatus {
                Id = 10
            });
            _mockUnitOfWork.Setup(x => x.CommitAsync()).ReturnsAsync(true);

            _mockSaleRepository.Setup(x => x.CustomFindLast(It.IsAny <Expression <Func <Sale, bool> > >(), It.IsAny <Expression <Func <Sale, int> > >())).ReturnsAsync(new Sale {
                CreatedAt = DateTime.Now
            });
            _mockShopUserRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <ShopUser, bool> > >())).ReturnsAsync(new List <ShopUser> {
                new ShopUser {
                    Shop = new Shop {
                        Id = 10
                    }
                }
            });

            var arrangeStatus = new List <UserStatus>();

            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.PreRegistration
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.WaitingForEmail
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.Active
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.Off
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.Inactive
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.WaitingForSMS
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.OnlyCatalog
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.PasswordExpired
            });
            arrangeStatus.Add(new UserStatus {
                Id = (int)UserStatusEnum.FriendInvitation
            });

            _mockUserStatusRepository.Setup(x => x.GetById(It.IsAny <int>()))
            .ReturnsAsync((int param) => arrangeStatus.AsQueryable().Where(x => x.Id == param).First());

            var hierarchyProcesses = new HierarchyProcessesService(
                _mockSaleFileRepository.Object,
                _mockEmailService.Object,
                _mockUserAccessCodeInviteRepository.Object,
                _mockUserPunctuationSourceRepository.Object,
                _mockUserPunctuationRepository.Object,
                _mockUserStatusLogRepository.Object,
                _mockLogger.Object,
                _mockHierarchyFileDataRepository.Object,
                _mockHierarchyFileDataErrorRepository.Object,
                _mockHierarchyFileRepository.Object,
                _mockFileStatusRepository.Object,
                _mockUserRepository.Object,
                _mockUserStatusRepository.Object,
                _mockShopRepository.Object,
                _mockShopUserRepository.Object,
                _mockUnitOfWork.Object,
                _mockOfficeRepository.Object,
                _mockSaleRepository.Object);

            var result = await hierarchyProcesses.ProcessesHierarchyFile();

            Assert.True(result);
        }
Exemple #4
0
        public async Task ProcessesHierarchyFile_ProcessingHierarchyRead_CreatingUserReturningTrue()
        {
            _mockSaleFileRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <SaleFile, bool> > >(), It.IsAny <Expression <Func <SaleFile, object> > >())).ReturnsAsync(new List <SaleFile> {
                new SaleFile {
                    Id = 10, FileStatus = new FileStatus {
                        Id = 5
                    }
                }
            });
            _mockHierarchyFileRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <HierarchyFile, bool> > >(), It.IsAny <Expression <Func <HierarchyFile, object> > >(), It.IsAny <Expression <Func <HierarchyFile, object> > >())).ReturnsAsync(new List <HierarchyFile> {
                new HierarchyFile {
                    Id = 10, FileStatus = new FileStatus {
                        Id = 10
                    }
                }
            });
            _mockHierarchyFileDataRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <HierarchyFileData, bool> > >())).ReturnsAsync(new List <HierarchyFileData> {
                new HierarchyFileData {
                    Id = 10, Office = "VENDEDOR"
                }
            });
            _mockShopRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <Shop, bool> > >())).ReturnsAsync(new List <Shop> {
                new Shop {
                    Id = 10
                }
            });
            _mockOfficeRepository.Setup(x => x.CustomFind(It.IsAny <Expression <Func <Office, bool> > >())).ReturnsAsync(new List <Office> {
                new Office {
                    Id = 10
                }
            });
            _mockOfficeRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new Office {
                Id = 10
            });
            _mockFileStatusRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new FileStatus {
                Id = 10
            });
            _mockUnitOfWork.Setup(x => x.CommitAsync()).ReturnsAsync(true);

            var hierarchyProcesses = new HierarchyProcessesService(
                _mockSaleFileRepository.Object,
                _mockEmailService.Object,
                _mockUserAccessCodeInviteRepository.Object,
                _mockUserPunctuationSourceRepository.Object,
                _mockUserPunctuationRepository.Object,
                _mockUserStatusLogRepository.Object,
                _mockLogger.Object,
                _mockHierarchyFileDataRepository.Object,
                _mockHierarchyFileDataErrorRepository.Object,
                _mockHierarchyFileRepository.Object,
                _mockFileStatusRepository.Object,
                _mockUserRepository.Object,
                _mockUserStatusRepository.Object,
                _mockShopRepository.Object,
                _mockShopUserRepository.Object,
                _mockUnitOfWork.Object,
                _mockOfficeRepository.Object,
                _mockSaleRepository.Object);

            var result = await hierarchyProcesses.ProcessesHierarchyFile();

            Assert.True(result);
        }