public void SetUp() { SingletonInitialize(); UsersManager = Substitute.For<IUsersManagement>(); AppraiserManager = Substitute.For<IAppraiserManagement>(); ReferenceManager = Substitute.For<IReferenceManagement>(); ReferenceManager.GetAllStates().Returns(new Dictionary<string, string>()); AppraisalCompanyManager = Substitute.For<IAppraisalCompanyManagement>(); StatusHistoryManager = Substitute.For<StatusHistoryManager>(Substitute.For<IChangeTrackingRepository>()); FeeManager = Substitute.For<IFeeManager>(); LicenseManager = Substitute.For<ILicenseManager>(); AppraiserAccessManager = Substitute.For<IAppraiserAccessManager>(); CryptographicProvider = Substitute.For<ICryptographicProvider>(); DocumentService = Substitute.For<IDocumentService>(); Target = new AppraiserUserService(UsersManager, AppraiserManager, ReferenceManager, AppraisalCompanyManager, StatusHistoryManager, FeeManager, LicenseManager, AppraiserAccessManager, CryptographicProvider, DocumentService, Substitute.For<IGeocodingDataService>()); }
public void CreateAppraiserUser_should_create_user() { var company = new AppraisalCompanyDetail() { Branches = new List<AppraisalCompanyBranch>() }; AppraisalCompanyManager.GetAppraisalCompanyById(1).Returns(company); var generalInfo = new CreateUserGeneralInfoViewModel() { Email = "email", Password = "******", RoleType = RoleType.Appraiser }; IAppraiserUserRepository appUserRepository = Substitute.For<IAppraiserUserRepository>(); var _taskManager = Substitute.For<ITaskManager>(); ReferenceManager.GetRoleWithoutCache(RoleType.Appraiser).Returns(new Role() { Id = (int)RoleType.Appraiser }); AppraiserManager = new AppraiserManagement(Substitute.For<IUserRepository>(), appUserRepository, ReferenceManager, _taskManager, Substitute.For<IAscGovLicenseService>()); Target = new AppraiserUserService(UsersManager, AppraiserManager, ReferenceManager, AppraisalCompanyManager, StatusHistoryManager, FeeManager, LicenseManager, AppraiserAccessManager, CryptographicProvider, DocumentService, Substitute.For<IGeocodingDataService>()); var contactInfo = new AppraiserUserContactViewModel() { PhysicalAddress = new AddressViewModel() }; var companyInfo = new AppraiserUserCompanyInfoViewModel() { CompanyID = 1 }; var appraiser = new AppraiserUserCreateViewModel() { GeneralInfo = generalInfo, Contact = contactInfo, CompanyInfo = companyInfo }; var serviceAreaRadiuses = new Dictionary<RefServiceAreaRadiuse, string>(); serviceAreaRadiuses.Add(new RefServiceAreaRadiuse() { ServiceAreaRadius = 1 }, "123"); ReferenceManager.GetServiceAreaRadiuses().Returns(serviceAreaRadiuses); //act Target.CreateAppraiserUser(appraiser); appUserRepository.Received().Add(Arg.Any<AppraiserUser>()); }