Пример #1
0
        public async Task FetchActiveOrganisationUsers_ReturnsSpecifiedUsers()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper  helper       = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var organisation     = helper.CreateOrganisation();
                var organisationUser = helper.CreateOrganisationUser(organisation, "*****@*****.**", 2);

                var organisation2     = helper.CreateOrganisation();
                var organisationUser2 = helper.CreateOrganisationUser(organisation2, "*****@*****.**", 2);

                database.Model.SaveChanges();

                var dataAccess = new OrganisationUserRequestEventHandlerDataAccess(database.WeeeContext);

                // Act
                var results = await dataAccess.FetchActiveOrganisationUsers(organisation.Id);

                // Assert
                foreach (var result in results)
                {
                    result.User.Email.Should().Be(organisationUser.AspNetUser.Email);
                }
            }
        }
Пример #2
0
        public async void FetchActiveOrganisationUsers_GivenOrganisationId_ReturnsActiveUsersLinkedToOrganisations()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                ModelHelper  helper       = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var organisation  = helper.CreateOrganisation();
                var organisation2 = helper.CreateOrganisation();

                var user  = helper.CreateOrganisationUser(organisation, "*****@*****.**", 2);
                var user2 = helper.CreateOrganisationUser(organisation, "*****@*****.**", 1);
                var user3 = helper.CreateOrganisationUser(organisation, "*****@*****.**", 2);

                database.Model.SaveChanges();

                var dataAccess = new GetActiveOrganisationUsersDataAccess(database.WeeeContext);

                var results = await dataAccess.FetchActiveOrganisationUsers(organisation.Id);

                foreach (var activeUser in results)
                {
                    activeUser.UserStatus.Value.Should().Be(2);
                    activeUser.OrganisationId.Should().Be(organisation.Id);
                }
            }
        }
Пример #3
0
        public async void FetchActiveOrganisationUsers_GivenOrganisationId_UsersShouldBeOrganisedByEmails()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                ModelHelper  helper       = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var organisation = helper.CreateOrganisation();
                var user         = helper.CreateOrganisationUser(organisation, "*****@*****.**", 2);
                var user2        = helper.CreateOrganisationUser(organisation, "*****@*****.**", 2);

                database.Model.SaveChanges();

                var dataAccess = new GetActiveOrganisationUsersDataAccess(database.WeeeContext);

                var results = await dataAccess.FetchActiveOrganisationUsers(organisation.Id);

                results.Should().BeInAscendingOrder(x => x.User.Email);
            }
        }
Пример #4
0
        public async Task FetchOrganisation_ReturnsSpecifiedOrganisation()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper  helper       = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var organisation = helper.CreateOrganisation();
                organisation.Name = "Organisation";

                database.Model.SaveChanges();

                var dataAccess = new OrganisationUserRequestEventHandlerDataAccess(database.WeeeContext);

                // Act
                var result = await dataAccess.FetchOrganisation(organisation.Id);

                // Assert
                result.Name.Should().Be(organisation.Name);
            }
        }
Пример #5
0
        public async Task FetchUser_ReturnsSpecifiedUser()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper  helper       = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var user  = helper.CreateUser("*****@*****.**", Weee.Tests.Core.Model.IdType.Guid);
                var user2 = helper.CreateUser("*****@*****.**", Weee.Tests.Core.Model.IdType.Guid);

                database.Model.SaveChanges();

                var dataAccess = new OrganisationUserRequestEventHandlerDataAccess(database.WeeeContext);

                // Act
                var result = await dataAccess.FetchUser(user.Id);

                // Assert
                result.Email.Should().Be(user.UserName);
            }
        }