Exemple #1
0
        public void Delete_EntityDoesntExists_NoChange()
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    var person = CreatePerson(1);

                    // Arrange
                    steps.BeginConversation();

                    // Act
                    steps.DeletePerson(person);
                }
            }
        }
Exemple #2
0
        public void Get_EntityDoesntExist_ReturnsNull()
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    // Arrange
                    steps.BeginConversation();

                    // Act
                    steps.IssueGetPerson(Guid.NewGuid());

                    // Assert
                    steps.VerifyRetrievedPersonIsNull();
                }
            }
        }
Exemple #3
0
        public void Delete_EntityExists_EntityIsRemoved()
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    var person = CreatePerson(1);

                    // Arrange
                    steps.BeginConversation();
                    steps.SavePerson(person);

                    // Act
                    steps.DeletePerson(person);

                    // Assert
                    steps.VerifyPersonDoesntExist(person);
                }
            }
        }
Exemple #4
0
        public void Get_EntityExists_ReturnsCorrespondingEntity()
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    var person = CreatePerson(1);

                    // Arrange
                    steps.BeginConversation();
                    steps.SavePerson(person);

                    // Act
                    steps.IssueGetPerson(person.Id);

                    // Assert
                    steps.VerifyRetrievedPerson(person);
                }
            }
        }
Exemple #5
0
        public void Update_EntityExists_EntityIsUpdated()
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    var person = CreatePerson(1);

                    // Arrange
                    steps.BeginConversation();
                    steps.AddPeopleToStore(new Person[] { person });

                    // Act
                    steps.UpdatePerson(person);

                    // Assert
                    steps.VerifyPersonExists(person);
                }
            }
        }
Exemple #6
0
        public void Update_EntityDoesntExists_ThrowInvalidOperationException()
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    var person = CreatePerson(1);

                    // Arrange
                    steps.BeginConversation();

                    // Act
                    Assert.Throws<InvalidOperationException>(() => steps.UpdatePerson(person));
                }
            }
        }
Exemple #7
0
        public void Save_EntityExists_ThrowInvalidOperationException()
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    var person = CreatePerson(1);

                    // Arrange
                    steps.BeginConversation();
                    steps.AddPeopleToStore(new Person[] { person });

                    // Act
                    Assert.Throws<InvalidOperationException>(() => steps.SavePerson(person));
                }
            }
        }
Exemple #8
0
        public void Save_EntityDoesntExists_EntityIsAddedAndIdIsAssigned()
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    var person = CreatePerson(1);

                    // Arrange
                    steps.BeginConversation();

                    // Act
                    steps.SavePerson(person);

                    // Assert
                    steps.VerifyIdIsAssigned(person);
                    steps.VerifyPersonExists(person);
                }
            }
        }
Exemple #9
0
        public void Linq_ReturnsQueryableSetOfEntities(int count)
        {
            using(var store = new Store(BuildConfiguration())) {
                OnStoreCreate(store);

                using(var steps = new Steps(store)) {
                    var people = Enumerable.Range(1, count).Select<int, Person>(CreatePerson).ToList();

                    // Given
                    steps.BeginConversation();
                    steps.AddPeopleToStore(people);

                    // When
                    steps.IssuePersonQuery();

                    // Then
                    steps.VerifyPersonQuery(people);
                }
            }
        }