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 }
public void RegisterAgent(RegisterModel model) { var newagent = new Agent { EmailAddress = model.Email }; var user = MembershipService.GetUser(model.UserName); if (user != null) { if (user.ProviderUserKey != null) newagent.GUID = new Guid(user.ProviderUserKey.ToString()); newagent.FirstName = model.UserName; newagent.Photo = "./../images/dotimages/avatar-placeholder.png"; newagent.GoogleMap = "USA"; UnitofWork.AgentRepository.Add(newagent); UnitofWork.Save(); } }
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 var fakeMemberShipService = new FakeMemberShipService(); #endregion #region Controller Construction + Mocking Context Controller = new TenantController(Uow, fakeMemberShipService, mockHelper.Object); 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 }