Пример #1
0
        public async Task UpdateShouldSucceed()
        {
            // Arrange
            var id                  = Guid.NewGuid();
            var name                = "Kalo";
            var description         = "SourceDescription";
            var businessUnit1Name   = "BSG";
            var businessUnit2Name   = "BSG1";
            var sourceBusinessUnit1 = new SourceBusinessUnit(businessUnit1Name);
            var sourceBusinessUnit2 = new SourceBusinessUnit(businessUnit2Name);
            var sourceBusinessUnits = new List <SourceBusinessUnit>()
            {
                sourceBusinessUnit1, sourceBusinessUnit2
            };
            var source = RepositoryHelper.ForSource.CreateSource(id, name, description, sourceBusinessUnits);

            source.RemoveSourceBusinessUnit(sourceBusinessUnit2);

            // Act
            await _repository.UpdateAsync(source);

            // Assert
            var data = RepositoryHelper.ForSource.GetSources();

            data.Should().HaveCount(1);
            var result = data.First();

            result.SourceBusinessUnits.Should().NotBeNull();
            result.SourceBusinessUnits.Count().Should().Be(1);
            result.SourceBusinessUnits.First().Should().Be(sourceBusinessUnit1);
        }
Пример #2
0
        public async Task DeleteShouldSucceed()
        {
            // Arrange
            var id                  = Guid.NewGuid();
            var name                = "Kalo";
            var description         = "SourceDescription";
            var businessUnit1Name   = "BSG";
            var businessUnit2Name   = "BSG1";
            var source              = new Source(id, name, description);
            var sourceBusinessUnit1 = new SourceBusinessUnit(businessUnit1Name);
            var sourceBusinessUnit2 = new SourceBusinessUnit(businessUnit2Name);
            var sourceBusinessUnits = new List <SourceBusinessUnit>()
            {
                sourceBusinessUnit1, sourceBusinessUnit2
            };

            RepositoryHelper.ForSource.CreateSource(id, name, description, sourceBusinessUnits);

            // Act
            await _repository.DeleteAsync(id, 0);

            // Assert
            var data = RepositoryHelper.ForSource.GetSources();

            data.Should().HaveCount(0);
        }
Пример #3
0
        public async Task ListShouldReturnAllRecords()
        {
            // Arrange
            var sourceBusinessUnitName = "BSG";
            var sourceBusinessUnit     = new SourceBusinessUnit(sourceBusinessUnitName);
            var sourceBusinessUnits    = new List <SourceBusinessUnit>()
            {
                sourceBusinessUnit
            };

            RepositoryHelper.ForSource.CreateSource(Guid.NewGuid(), "name-1", "description", sourceBusinessUnits);
            RepositoryHelper.ForSource.CreateSource(Guid.NewGuid(), "name-2", "description", sourceBusinessUnits);
            RepositoryHelper.ForSource.CreateSource(Guid.NewGuid(), "name-3", "description", sourceBusinessUnits);

            // Act
            var result = await _repository.ListAsync(null, null, null);

            // Assert
            result.Should().HaveCount(3);
        }
Пример #4
0
        public async Task GetByIdShouldSucceed()
        {
            // Arrange
            var id                     = Guid.NewGuid();
            var name                   = "name";
            var description            = "description";
            var sourceBusinessUnitName = "BSG";
            var sourceBusinessUnit     = new SourceBusinessUnit(sourceBusinessUnitName);
            var sourceBusinessUnits    = new List <SourceBusinessUnit>()
            {
                sourceBusinessUnit
            };

            RepositoryHelper.ForSource.CreateSource(id, name, description, sourceBusinessUnits);

            // Act
            var result = await _repository.GetAsync(id);

            // Assert
            result.Should().NotBeNull();
        }