public void Setup()
        {
            var organizationRepository = new OrganizationSqlRepository(CreateContext());

            _knownOrganization   = new Organization(Guid.NewGuid().ToString());
            _unknownOrganization = new Organization(Guid.NewGuid().ToString());
            organizationRepository.Store(_knownOrganization);
            organizationRepository.Store(_unknownOrganization);
        }
Пример #2
0
        public async Task Store_returns_newly_created_organization()
        {
            // Arrange

            var sut          = new OrganizationSqlRepository(_context);
            var organization = new Organization(Guid.NewGuid().ToString());

            // Act

            await sut.Store(organization);

            // Assert

            var reconstitutedOrganization = await sut.GetBy(organization.Identifier);

            reconstitutedOrganization.Name.ShouldBe(organization.Name);
            reconstitutedOrganization.IsEnabled.ShouldBe(organization.IsEnabled);
        }
Пример #3
0
        public async Task Store_updates_existing_organization()
        {
            // Arrange

            var newName      = Guid.NewGuid().ToString();
            var sut          = new OrganizationSqlRepository(_context);
            var organization = new Organization(Guid.NewGuid().ToString());
            await sut.Store(organization);

            organization.UpdateName(newName);

            // Act

            await sut.Store(organization);

            // Assert

            var reconstitutedOrganization = await sut.GetBy(organization.Identifier);

            reconstitutedOrganization.Name.Name.ShouldBe(newName);
        }
Пример #4
0
        public async Task SearchBy_returns_all_organizations_matching_name()
        {
            // Arrange

            var uniqueText    = Guid.NewGuid().ToString();
            var sut           = new OrganizationSqlRepository(_context);
            var organization1 = new Organization(Guid.NewGuid().ToString() + uniqueText);
            var organization2 = new Organization(Guid.NewGuid().ToString() + uniqueText);
            await sut.Store(organization1);

            await sut.Store(organization2);

            // Act

            var results = sut.SearchBy(uniqueText).ToList();

            // Assert

            results.Count.ShouldBe(2);
            results.Any(x => x.Identifier.Equals(organization1.Identifier)).ShouldBeTrue();
            results.Any(x => x.Identifier.Equals(organization2.Identifier)).ShouldBeTrue();
        }