public GetNotificationsToCopyForUserHandlerTests() { userContext = new TestUserContext(UserWithNotificationsId); context = new TestIwsContext(userContext); var notification1 = NotificationApplicationFactory.Create(UserWithNotificationsId, NotificationType.Recovery, UKCompetentAuthority.England, 1); EntityHelper.SetEntityId(notification1, Notification1Id); var importer1 = ImporterFactory.Create(Notification1Id, new Guid("DA0C2B9A-3370-4265-BA0D-2F7030241E7C")); ObjectInstantiator<NotificationApplication>.SetProperty(x => x.WasteType, WasteType.CreateOtherWasteType("wood"), notification1); var notification2 = NotificationApplicationFactory.Create(UserWithNotificationsId, NotificationType.Recovery, UKCompetentAuthority.England, 2); EntityHelper.SetEntityId(notification2, Notification2Id); var importer2 = ImporterFactory.Create(Notification2Id, new Guid("CD8FE7F5-B0EF-47E4-A198-D1E531A6CCDF")); ObjectInstantiator<NotificationApplication>.SetProperty(x => x.WasteType, WasteType.CreateRdfWasteType(new List<WasteAdditionalInformation> { WasteAdditionalInformation.CreateWasteAdditionalInformation("toffee", 1, 10, WasteInformationType.AshContent) }), notification2); var notification3 = NotificationApplicationFactory.Create(UserWithNotificationsId, NotificationType.Disposal, UKCompetentAuthority.England, 1); EntityHelper.SetEntityId(notification3, Notification3Id); var importer3 = ImporterFactory.Create(Notification3Id, new Guid("AF7ADA0A-E81B-4A7F-9837-52591B219DD3")); ObjectInstantiator<NotificationApplication>.SetProperty(x => x.WasteType, WasteType.CreateOtherWasteType("wood"), notification3); var destinationNotification = NotificationApplicationFactory.Create(UserWithNotificationsId, NotificationType.Recovery, UKCompetentAuthority.England, 1); EntityHelper.SetEntityId(destinationNotification, DestinationNotificationId); var destinationNotification2 = NotificationApplicationFactory.Create(UserWithoutNotificationsId, NotificationType.Recovery, UKCompetentAuthority.England, 1); EntityHelper.SetEntityId(destinationNotification2, DestinationNotificationId2); context.NotificationApplications.AddRange(new[] { notification1, notification2, notification3, destinationNotification, destinationNotification2 }); context.Exporters.AddRange(new[] { CreateExporter(Notification1Id), CreateExporter(Notification2Id), CreateExporter(Notification3Id) }); context.Importers.AddRange(new[] { importer1, importer2, importer3 }); handler = new GetNotificationsToCopyForUserHandler(context, userContext); }
public void Edit_UserHasInsufficientSecurityClearance_ThrowsDomainValidationException() { var supplierId = Guid.NewGuid(); var currencyId = Guid.NewGuid(); var instructions = "some edited instructions"; var orderRepositoryStub = MockRepository.GenerateStub <IOrderRepository>(); orderRepositoryStub.Stub(x => x.GetById(_orderForEditId)).Return(_orderForEdit); var supplierRepositoryStub = MockRepository.GenerateStub <ISupplierRepository>(); supplierRepositoryStub.Stub(x => x.GetById(supplierId)).Return(new Supplier { Id = supplierId, Name = "Supplier for edit" }); var currencyRepositoryStub = MockRepository.GenerateStub <ICurrencyRepository>(); currencyRepositoryStub.Stub(x => x.GetById(currencyId)).Return(new Currency { Id = currencyId, Name = "USD" }); _orderService = OrderServiceTestHelper.CreateOrderService( orderRepositoryStub, supplierRepositoryStub, currencyRepositoryStub, TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public)); Edit(_orderForEditId, supplierId, currencyId, instructions); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public PersonGreeterTests() { _personRepo = new Mock_PersonRepository(); _user = new TestUserContext(); _greeterService = new PersonGreeterService(_personRepo, _user); }
private static IConsignmentRepository GetConsignmentRepository(Guid consignmentId, int itemCount) { var consignmentRepositoryStub = MockRepository.GenerateStub <IConsignmentRepository>(); if (consignmentId != Guid.Empty) { consignmentRepositoryStub.Stub(x => x.GetById(consignmentId)).Return( new Consignment { Id = Guid.NewGuid(), ConsignmentNo = "CR2000", CreatedBy = TestUserContext.CreateAdminUser(), DateCreated = DateTime.UtcNow, Supplier = new Supplier { Id = Guid.NewGuid(), Name = "Gael Ltd" } }); consignmentRepositoryStub.Stub(x => x.GetConsignmentItemCount(consignmentId)).Return(itemCount); } else { consignmentRepositoryStub.Stub(x => x.GetById(consignmentId)).Return(null); } return(consignmentRepositoryStub); }
public static InstrumentService CreateForSearch(IInstrumentRepository repository) { return(new InstrumentService( TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Member), repository, MockRepository.GenerateStub <IQueueDispatcher <IMessage> >())); }
public void Setup() { _domainValidationException = null; _savedBankDetails = null; _userContext = TestUserContext.Create( "*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Manager | UserRole.Member); }
public AuthenticationTests() { var dbContextFactory = new InMemoryDbContextFactory(); userContext = new TestUserContext(); authenticationService = new AuthenticationService(userContext, dbContextFactory); }
public void Setup() { _userContext = TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Manager | UserRole.Member); _domainValidationException = null; _savedCertificate = null; AppDateTime.GetUtcNow = () => _dateCreated; }
public static JobItemService Create( IJobItemRepository jobItemRepository, Guid jobId, Guid instrumentId, Guid initialStatusId, Guid fieldId, int jobItemCount) { return(Create( jobItemRepository, jobId, instrumentId, initialStatusId, fieldId, jobItemCount, TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Member))); }
public void CreateDeliveriesFromPendingItems_ValidPendingDeliveryItems_DeliveriesCreated() { var dispatcher = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >(); var userRepository = new UserAccountRepository(); var user = userRepository.GetByEmail("*****@*****.**", false); var userContext = new TestUserContext(user); var quoteRepository = new QuoteRepository(); var quoteItemRepository = new QuoteItemRepository(); var customerRepository = new CustomerRepository(); var jobRepository = new JobRepository(); var jobItemRepository = new JobItemRepository(); var listItemRepository = new ListItemRepository(); var entityIdProvider = new DirectEntityIdProvider(); var instrumentRepository = new InstrumentRepository(); var deliveryRepository = new DeliveryRepository(); var deliveryItemRepository = new DeliveryItemRepository(); var customerId1 = Guid.NewGuid(); var customerId2 = Guid.NewGuid(); var job1Id = Guid.NewGuid(); var job2Id = Guid.NewGuid(); var job3Id = Guid.NewGuid(); var jobItem1Id = Guid.NewGuid(); var jobItem2Id = Guid.NewGuid(); var jobItem3Id = Guid.NewGuid(); var jobItem4Id = Guid.NewGuid(); var jobItem5Id = Guid.NewGuid(); var jobItem6Id = Guid.NewGuid(); var jobItem7Id = Guid.NewGuid(); var jobItem8Id = Guid.NewGuid(); var jobItem9Id = Guid.NewGuid(); CreateDeliveriesFromPendingItemsHelper.CreateContextForPendingItemTests( customerId1, customerId2, job1Id, job2Id, job3Id, jobItem1Id, jobItem2Id, jobItem3Id, jobItem4Id, jobItem5Id, jobItem6Id, jobItem7Id, jobItem8Id, jobItem9Id); var deliveryItemService = new DeliveryItemService( userContext, deliveryRepository, deliveryItemRepository, jobItemRepository, quoteItemRepository, listItemRepository, customerRepository, dispatcher); var deliveryService = new DeliveryService(userContext, deliveryRepository, deliveryItemService, customerRepository, entityIdProvider, dispatcher); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem1Id, customerId1, "some notes"); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem2Id, customerId1, "some notes"); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem3Id, customerId1, "some notes"); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem4Id, customerId1, "some notes"); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem5Id, customerId1, "some notes"); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem6Id, customerId1, "some notes"); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem7Id, customerId1, "some notes"); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem8Id, customerId2, "some notes"); deliveryItemService.CreatePending(Guid.NewGuid(), jobItem9Id, customerId2, "some notes"); deliveryService.CreateDeliveriesFromPendingItems(); var deliveries = deliveryService.GetDeliveries().ToList(); Assert.AreEqual(2, deliveries.Count); var deliveryItems = deliveryItemService.GetDeliveryItems(deliveries[0].Id).ToList(); Assert.AreEqual(7, deliveryItems.Count); }
public FavoriteEventsTests() { var dbContextFactory = new InMemoryDbContextFactory(); context = new TestUserContext(); events = new FavoriteEventsService(context, dbContextFactory); auth = new AuthenticationService(context, dbContextFactory); }
public GetNewInternalUsersHandlerTests() { this.context = new TestIwsContext(); context.InternalUsers.AddRange(new InternalUserCollection().Users); this.userContext = new TestUserContext(Guid.Empty); handler = new GetNewInternalUsersHandler(context, new InternalUserMap(), userContext); }
public BirthdayServiceTests() { _database = new TestDatabaseContext(); _user = new TestUserContext(); _personGreeterService = new Mock_PersonService(); _personRepo = new Mock_PersonRepository(); _birthdayService = new BirthdayService(_personRepo, _user, _personGreeterService); }
public void GetById_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { _orderService = OrderServiceTestHelper.CreateOrderService( MockRepository.GenerateStub <IOrderRepository>(), MockRepository.GenerateStub <ISupplierRepository>(), MockRepository.GenerateStub <ICurrencyRepository>(), TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public)); GetById(Guid.NewGuid()); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public void Create_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var supplierId = Guid.NewGuid(); _consignmentService = ConsignmentServiceFactory.Create(supplierId, TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Public)); CreateConsignment(id, supplierId); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public void GetQuotes_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { _quoteService = QuoteServiceTestHelper.CreateQuoteService( MockRepository.GenerateStub<IQuoteRepository>(), MockRepository.GenerateStub<ICustomerRepository>(), MockRepository.GenerateStub<ICurrencyRepository>(), TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public)); GetQuotes(); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Quotes.Messages.InsufficientSecurity)); }
public void GetCertificates_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { _certificateService = CertificateServiceFactory.Create( TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public), MockRepository.GenerateStub <IListItemRepository>(), MockRepository.GenerateStub <ICertificateRepository>(), MockRepository.GenerateStub <IJobItemRepository>()); GetCertificates(); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public static JobService Create(IJobRepository jobRepository, IJobAttachmentDataRepository attachmentRepository) { return(new JobService( TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Member), attachmentRepository, jobRepository, MockRepository.GenerateStub <IListItemRepository>(), MockRepository.GenerateStub <ICustomerRepository>(), MockRepository.GenerateStub <IEntityIdProvider>(), MockRepository.GenerateStub <IQueueDispatcher <IMessage> >())); }
public static async Task CreateUser( this TestUserContext userContext, IAuthenticationService authenticationService, string nickname = "RandomFellow", string password = "******" ) { var token = await authenticationService.SignUp(nickname, password); userContext.UseToken(token); }
public static OpenDataPublishingController GetTestOpenDataPublishingController(IDocumentSession db) { var testUserContext = new TestUserContext(); var userContextMock = new Mock <IUserContext>(); userContextMock.Setup(u => u.User).Returns(testUserContext.User); var publishingService = new OpenDataPublishingRecordService(db, new RecordValidator()); return(new OpenDataPublishingController(db, publishingService, userContextMock.Object)); }
public void GetCurrencies_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { _userContext = TestUserContext.Create( "*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public); _currencyService = new CurrencyService( _userContext, MockRepository.GenerateStub <ICurrencyRepository>(), MockRepository.GenerateStub <IQueueDispatcher <IMessage> >()); GetCurrencies(); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public FavoriteUsersTests() { var dbContextFactory = new InMemoryDbContextFactory(); firstContext = new TestUserContext(); firstFavoriteUsers = new FavoriteUsersService(firstContext, dbContextFactory); firstAuth = new AuthenticationService(firstContext, dbContextFactory); secondContext = new TestUserContext(); secondFavoriteUsers = new FavoriteUsersService(secondContext, dbContextFactory); secondAuth = new AuthenticationService(secondContext, dbContextFactory); }
public static void TestFixtureSetup(TestContext context) { // Set up DbContext and IdentityFramework UnitTestContext = new TestUserContext(); UserRepositoryClass = new UserRepository( UnitTestContext.UserDbContext, UnitTestContext.UserManager, UnitTestContext.SignInManager, UnitTestContext.RoleManager, UnitTestContext.JwtTokenHandler); }
public void Approve_JobIdNotSupplied_ArgumentExceptionThrown() { var id = Guid.Empty; var customerId = Guid.NewGuid(); var typeId = Guid.NewGuid(); var jobRepository = MockRepository.GenerateMock <IJobRepository>(); _jobService = JobServiceFactory.CreateForApproval(jobRepository, id, typeId, customerId, TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.JobApprover)); ApproveJob(id); }
public GroupsTests() { var dbContextFactory = new InMemoryDbContextFactory(); firstContext = new TestUserContext(); firstGroups = new GroupsService(firstContext, dbContextFactory); firstAuth = new AuthenticationService(firstContext, dbContextFactory); secondContext = new TestUserContext(); secondGroups = new GroupsService(secondContext, dbContextFactory); secondAuth = new AuthenticationService(secondContext, dbContextFactory); }
public void Create_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var customerId = Guid.NewGuid(); var fao = "Graham Robertson"; _deliveryService = DeliveryServiceFactory.Create( TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public), MockRepository.GenerateStub <IDeliveryRepository>(), CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId)); Create(id, customerId, fao); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public void Edit_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrow() { var name = "CAD"; var displayMessage = "All prices in Canadian Dollars"; _userContext = TestUserContext.Create( "*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Member); var currencyRepositoryStub = MockRepository.GenerateMock <ICurrencyRepository>(); _currencyService = new CurrencyService(_userContext, currencyRepositoryStub, MockRepository.GenerateStub <IQueueDispatcher <IMessage> >()); EditCurrency(_currencyForEditId, name, displayMessage); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public void Approve_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var customerId = Guid.NewGuid(); var typeId = Guid.NewGuid(); var jobRepository = MockRepository.GenerateMock <IJobRepository>(); _jobService = JobServiceFactory.CreateForApproval(jobRepository, id, typeId, customerId, TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Member)); ApproveJob(id); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Jobs.Messages.InsufficientSecurityClearance)); }
public void account_not_in_iao_group() { var testUserContext = new TestUserContext("Test User", "Tester", "*****@*****.**", false); var userContextMock = new Mock <IUserContext>(); userContextMock.Setup(u => u.User).Returns(testUserContext.User); var accountController = new AccountController(userContextMock.Object); var account = accountController.Get(); account.IsIaoUser.Should().BeFalse(); }
public void account_in_iao_group() { var testUserContext = new TestUserContext(); var userContextMock = new Mock <IUserContext>(); userContextMock.Setup(u => u.User).Returns(testUserContext.User); var accountController = new AccountController(userContextMock.Object); var account = accountController.Get(); account.IsIaoUser.Should().BeTrue(); }
// [Ignore] public void LookupPanelTestWithLayoutWithPermissions() { //показ листовой формы с учётом полномочий TestUserContext.Init(); using (ModelUserContext context = ModelUserContext.Instance) { //Lookup2ListItem bo = Lookup2ListItem.CreateInstance(); var panel = new TestLookupPanelUI(); panel.LoadData(); BaseFormManager.ShowSimpleFormModal(panel); } TestUserContext.Clear(); }
public NotificationStatusChangeEventHandlerTests() { context = new TestIwsContext(); var userContext = new TestUserContext(UserId); handler = new NotificationStatusChangeEventHandler(context, userContext); context.Users.Add(UserFactory.Create(UserId, AnyString, AnyString, AnyString, AnyString)); notificationAssessment = new NotificationAssessment(NotificationId); receivedEvent = new NotificationStatusChangeEvent(notificationAssessment, NotificationStatus.Submitted); }
public FinancialGuaranteeStatusChangeEventHandlerTests() { context = new TestIwsContext(); var userContext = new TestUserContext(UserId); handler = new FinancialGuaranteeStatusChangeEventHandler(context, userContext); context.Users.Add(UserFactory.Create(UserId, AnyString, AnyString, AnyString, AnyString)); financialGuarantee = new FinancialGuaranteeCollection(new Guid("68787AC6-7CF5-4862-8E7E-77E20172AECC")).AddFinancialGuarantee(new DateTime(2015, 1, 1)); receivedEvent = new FinancialGuaranteeStatusChangeEvent(financialGuarantee, FinancialGuaranteeStatus.ApplicationReceived); }
public SetUserApprovalsHandlerTests() { userContext = new TestUserContext(Guid.Empty); context = new TestIwsContext(userContext); context.InternalUsers.AddRange(new InternalUserCollection().Users); var userManager = A.Fake<UserManager<ApplicationUser>>(); handler = new SetUserApprovalsHandler(context, userContext, userManager); approvePendingAdminMessage = new SetUserApprovals(new[] { new UserApproval(InternalUserCollection.AdminPendingId, ApprovalAction.Approve, UserRole.Administrator) }); getUserStatusFromContext = (id, ctxt) => { return ctxt.InternalUsers.Single(u => u.UserId == id.ToString()).Status; }; }
public RecordMovementStatusChangeTest() { notificationId = new Guid("1BDB59A9-349E-43E2-9D81-51955FDBF735"); userId = TestIwsContext.UserId; //TODO: create ObjectInstantator<T>.CreateInstance(params) method... var flags = BindingFlags.NonPublic | BindingFlags.Instance; var culture = CultureInfo.InvariantCulture; var parameters = new object[] { 1, notificationId, new DateTime(2015, 1, 1), userId }; movement = (Movement)Activator.CreateInstance( typeof(Movement), flags, null, parameters, culture); context = new TestIwsContext(); context.Users.Add(UserFactory.Create(userId, AnyString, AnyString, AnyString, AnyString)); var userContext = new TestUserContext(userId); handler = new RecordMovementStatusChange(context, userContext); receivedEvent = new MovementStatusChangeEvent(movement, MovementStatus.Submitted); }