public AccountController(IGenericUnitofWork uow, IMembershipService membershipService, IUserHelper userHelper ,IEmailService emailService) { UnitofWork = uow; MembershipService = membershipService; UserHelper = userHelper; EmailService = emailService; AccountHelper = new AccountHelper(uow, membershipService, userHelper, emailService); }
public void Initialize() { // Arrange #region AccountHelperTest #region Repo var maintenanceCompanyLookUpRepo = new FakeMaintenanceCompanyLookUpRepository(); var maintenanceCompanyRepo = new FakeMaintenanceCompanyRepository(); var maintenanceCompanySpecializationRepo = new FakeMaintenanceCompanySpecializationRepository(); var maintenanceCustomServicesRepo = new FakeMaintenanceCustomServiceRepository(); var maintenanceExteriorRepo = new FakeMaintenanceExteriorRepository(); var maintenanceInteriorRepo = new FakeMaintenanceInteriorRepository(); var maintenanceNewConstructionRepo = new FakeMaintenanceNewConstructionRepository(); var maintenanceRepairRepo = new FakeMaintenanceRepairRepository(); var maintenanceUtilityRepo = new FakeMaintenanceUtilityRepository(); var currencyRepo = new FakeCurrencyRepository(); var specialistProfileCommentRepo = new FakeSpecialistProfileCommentRepository(); var specialistWorkRepo = new FakeSpecialistWorkRepository(); var agentRepo = new FakeAgentRepository(); var ownerRepo = new FakeOwnerRepository(); var specialistRepo = new FakeSpecialistRepository(); var tenantRepo = new FakeTenantRepository(); var providerRepo = new FakeMaintenanceProviderRepository(); Uow = new UnitofWork { MaintenanceCompanyLookUpRepository = maintenanceCompanyLookUpRepo, MaintenanceCompanyRepository = maintenanceCompanyRepo, MaintenanceCompanySpecializationRepository = maintenanceCompanySpecializationRepo, MaintenanceCustomServiceRepository = maintenanceCustomServicesRepo, MaintenanceExteriorRepository = maintenanceExteriorRepo, MaintenanceInteriorRepository = maintenanceInteriorRepo, MaintenanceNewConstructionRepository = maintenanceNewConstructionRepo, MaintenanceRepairRepository = maintenanceRepairRepo, MaintenanceUtilityRepository = maintenanceUtilityRepo, CurrencyRepository = currencyRepo, SpecialistProfileCommentRepository = specialistProfileCommentRepo, SpecialistWorkRepository = specialistWorkRepo, AgentRepository = agentRepo, OwnerRepository = ownerRepo, SpecialistRepository = specialistRepo, TenantRepository = tenantRepo, MaintenanceProviderRepository = providerRepo }; #endregion #region Mocking IUserHelper #region AccountHelper UserHelper var mockHelper = new Mock<IUserHelper>(); mockHelper. Setup(x => x.UserIdentity). Returns(new UserIdentity(Uow, new FakeMembershipProvider())); mockHelper. Setup(x => x.AgentPrivateProfileHelper). Returns(AgentPrivateProfileHelperMock); mockHelper. Setup(x => x.OwnerPrivateProfileHelper). Returns(OwnerPrivateProfileHelperMock); mockHelper. Setup(x => x.ProviderPrivateProfileHelper). Returns(ProviderPrivateProfileHelperMock); mockHelper. Setup(x => x.SpecialistPrivateProfileHelper). Returns(SpecialistPrivateProfileHelperMock); mockHelper. Setup(x => x.TenantPrivateProfileHelper). Returns(TenantPrivateProfileHelperMock); #endregion #endregion #region Mocking MemberShipService //MembershipService Optional var membershipMock = new Mock<IMembershipService>(); //var userMock = new Mock<MembershipUser>(); //var secondSpecialist = professionalRepo.MyList[1]; //userMock.Setup(u => u.ProviderUserKey).Returns(secondSpecialist.GUID); //userMock.Setup(u => u.UserName).Returns(secondSpecialist.FirstName); //membershipMock.Setup(s => s.GetUser(It.IsAny<string>())).Returns(userMock.Object); #endregion #region Controller Construction + Mocking Context Controller = new AccountHelper(Uow, membershipMock.Object, mockHelper.Object, new MockEmailService()); Controller.MockHttpContext(); #endregion #region ExpectedResult Helper ExpectedOwner = new ExpectedHelper(Uow).GetExpectedOwner(); ExpectedAgent = new ExpectedHelper(Uow).GetExpectedAgent(); ExpectedTenant = new ExpectedHelper(Uow).GetExpectedTenant(); ExpectedProvider = new ExpectedHelper(Uow).GetExpectedProvider(); ExpectedSpecialist = new ExpectedHelper(Uow).GetExpectedSpecialist(); #endregion #endregion //AccountHelperTest }