예제 #1
0
        public async Task AfterScenario()
        {
            var test = objectContainer.Resolve <UITest>();

            test.Driver?.Quit();

            if (context.ContainsKey(ContextKeys.CreatedOrder))
            {
                var orderCallOffId = context.Get <Order>(ContextKeys.CreatedOrder).CallOffId;

                var dbContext = GetDbContext(test.OrdapiConnectionString);

                if (await dbContext.Order.SingleOrDefaultAsync(o => o.CallOffId == orderCallOffId) is not null)
                {
                    dbContext.Remove(await dbContext.Order.SingleAsync(s => s.CallOffId == orderCallOffId));
                    await dbContext.SaveChangesAsync();
                }
            }

            if (context.ContainsKey(ContextKeys.User))
            {
                if (context.ContainsKey(ContextKeys.RelatedOrganisation))
                {
                    var relatedOrganisation = context.Get <RelatedOrganisation>(ContextKeys.RelatedOrganisation);
                    await RelatedOrganisationsHelper.DeleteRelatedOrganisation(test.IsapiConnectionString, relatedOrganisation);
                }

                var user = (User)context[ContextKeys.User];
                await UsersHelper.Delete(test.IsapiConnectionString, user);
            }
        }
예제 #2
0
        public async Task CreateUser(UserType userType)
        {
            Organisation organisation = await Organisation.GetByODSCode("27D", Test.IsapiConnectionString);

            var user = UsersHelper.GenerateRandomUser(organisation.OrganisationId, new User()
            {
                UserType = userType
            });
            await UsersHelper.Create(Test.IsapiConnectionString, user);

            var allOrgs = await RelatedOrganisationsHelper.GetAllOrganisations(Test.IsapiConnectionString);

            var allRelated = await RelatedOrganisationsHelper.GetAllRelatedOrganisationsForOrganisation(Test.IsapiConnectionString, user.PrimaryOrganisationId);

            var relatedOrgansation = RelatedOrganisationsHelper.GenerateRelatedOrganisation(allOrgs, allRelated, user.PrimaryOrganisationId);

            await RelatedOrganisationsHelper.AddRelatedOrganisation(Test.IsapiConnectionString, relatedOrgansation);

            Context.Add(ContextKeys.User, user);
            Context.Add(ContextKeys.RelatedOrganisation, relatedOrgansation);
        }