Exemplo n.º 1
0
        private async Task ActionAndAssertApprovalDate(Action <Guid> assertion, DateTime?approvalDate, DateTime windowStartDate)
        {
            using (database = new DatabaseWrapper())
            {
                var helper       = new ModelHelper(database.Model);
                var domainHelper = new DomainHelper(database.WeeeContext);
                var userContext  = A.Fake <IUserContext>();

                A.CallTo(() => userContext.UserId).Returns(Guid.Parse(database.Model.AspNetUsers.First().Id));
                A.CallTo(() => quarterWindowFactory.GetQuarterWindow(A <Quarter> ._))
                .Returns(new Domain.DataReturns.QuarterWindow(windowStartDate, windowStartDate.AddDays(1), QuarterType.Q1));

                await CreateReturnToCopy(approvalDate);

                var message = new CopyReturn(@return.Id);

                var authorization = new AuthorizationBuilder().AllowEverything().Build();

                handler = new CopyReturnHandler(authorization,
                                                database.WeeeContext,
                                                userContext,
                                                quarterWindowFactory);

                var result = await handler.HandleAsync(message);

                @return      = database.WeeeContext.Returns.AsNoTracking().First(r => r.Id == message.ReturnId);
                copiedReturn = database.WeeeContext.Returns.First(r => r.Id == result);

                assertion(result);
            }
        }
Exemplo n.º 2
0
        private async Task ArrangeActAndCallAssertions(Action <Guid> assertions)
        {
            using (database = new DatabaseWrapper())
            {
                // Arrange
                var helper       = new ModelHelper(database.Model);
                var domainHelper = new DomainHelper(database.WeeeContext);
                var userContext  = A.Fake <IUserContext>();

                A.CallTo(() => userContext.UserId).Returns(Guid.Parse(database.Model.AspNetUsers.First().Id));

                await CreateReturnToCopy(DateTime.Now);

                var message = new CopyReturn(@return.Id);

                var authorization = new AuthorizationBuilder().AllowEverything().Build();

                handler = new CopyReturnHandler(authorization,
                                                database.WeeeContext,
                                                userContext,
                                                quarterWindowFactory);

                // Act
                var result = await handler.HandleAsync(message);

                @return      = database.WeeeContext.Returns.AsNoTracking().First(r => r.Id == message.ReturnId);
                copiedReturn = database.WeeeContext.Returns.First(r => r.Id == result);

                // Assert
                assertions(result);
            }
        }