Exemplo n.º 1
0
        public void ReadModelRepositoryShouldThrowExceptionIfDuplicateItemIsAdded()
        {
            var testItem   = new Test(Guid.NewGuid());
            var repository = new TestModelRepository();

            repository.Add(testItem);

            Action act = () => repository.Add(testItem);

            act.ShouldThrow <ModelRepositoryAddException>();
        }
Exemplo n.º 2
0
        public void ReadModelRepositoryAddMethodShouldThrowExceptionIfItemWIthEmptyIsAdded()
        {
            var    repository = new TestModelRepository();
            Action act        = () => repository.Add(new Test(Guid.Empty));

            act.ShouldThrow <ModelRepositoryAddException>();
        }
Exemplo n.º 3
0
        public void ReadModelRepositoryAddMethodShouldThrowExceptionIfNullIsAdded()
        {
            var    repository = new TestModelRepository();
            Action act        = () => repository.Add(null);

            act.ShouldThrow <ModelRepositoryAddException>();
        }
Exemplo n.º 4
0
        public void ReadModelRepositoryShouldReturnsAllItems()
        {
            var item1 = new Test(Guid.NewGuid())
            {
                Name = "Testitem 1"
            };
            var item2 = new Test(Guid.NewGuid())
            {
                Name = "Testitem 2"
            };

            var repository = new TestModelRepository();

            repository.Add(item1);
            repository.Add(item2);
            repository.GetAll().Count().Should().Be(2);
        }
Exemplo n.º 5
0
        public void ReadModelRepositoryShouldReturnAnItemById()
        {
            var guid = Guid.NewGuid();
            var item = new Test(guid)
            {
                Name = "Testitem"
            };

            var repository = new TestModelRepository();

            repository.Add(item);
            repository.GetById(guid).Should().Be(item);
        }
Exemplo n.º 6
0
        public void ReadModelRepositoryShouldUpdateAnItem()
        {
            var guid = Guid.NewGuid();
            var item = new Test(guid)
            {
                Name = "Testitem"
            };
            var itemUpdate = new Test(guid)
            {
                Name = "Testitem Update"
            };

            var repository = new TestModelRepository();

            repository.Add(item);
            repository.Update(itemUpdate);
            repository.GetById(guid).Name.Should().Be("Testitem Update");
        }