コード例 #1
0
        public void Delete_WithCommit_ShouldChangeOperationTypeToInsertAndSetAsDone(
            object entity,
            FakeDataSet<object> dataSet)
        {
            // Act

            dataSet.Delete(entity);
            dataSet.Commit();

            // Assert

            var operation = dataSet.InternalOperations.Single();

            operation.Type.Should().Be(BaseDataSetOperationType.Insert);
            operation.Done.Should().Be.True();
        }
コード例 #2
0
        public void Delete_WithCommitAndRollback_ShouldDeleteAfterCommitAndInsertAfterRollback(
            object entity,
            FakeDataSet<object> dataSet)
        {
            // Act

            dataSet.Delete(entity);
            dataSet.Commit();

            // Assert

            dataSet.Inserts.Should().Be(0);
            dataSet.Deletes.Should().Be(1);
            dataSet.Updates.Should().Be(0);

            dataSet.Rollback();

            dataSet.Inserts.Should().Be(1);
            dataSet.Deletes.Should().Be(1);
            dataSet.Updates.Should().Be(0);
        }
コード例 #3
0
        public void Dispose_ShouldDisposeTheEntitiesStoredOnOperations(
            Mock<IDisposable> entity1,
            Mock<IDisposable> entity2,
            FakeDataSet<object> dataSet)
        {
            // Arrange

            dataSet.SetUpGet(entity1.Object);

            dataSet.Update(entity2.Object);
            dataSet.Commit();

            // Act

            dataSet.Dispose();

            // Assert

            entity1.Verify(e => e.Dispose(), Times.Once);
            entity2.Verify(e => e.Dispose(), Times.Once);
        }
コード例 #4
0
        public void Update_WithCommit_ShouldSetTheOriginalEntityToOldEntityAndSetAsDone(
            object entity1,
            object entity2,
            FakeDataSet<object> dataSet)
        {
            // Act

            dataSet.SetUpGet(entity1);

            dataSet.Update(entity2);
            dataSet.Commit();

            // Assert

            var operation = dataSet.InternalOperations.Single();

            operation.Type.Should().Be(BaseDataSetOperationType.Update);
            operation.CurrentEntity.Should().Not.Be.Null();
            operation.CurrentEntity.Should().Be.EqualTo(entity1);
            operation.PreviousEntity.Should().Be.EqualTo(entity2);
            operation.Done.Should().Be.True();
        }
コード例 #5
0
        public void Update_WithCommitAndRollback_ShouldCallUpdateTwice(
            object entity,
            FakeDataSet<object> dataSet)
        {
            // Act

            dataSet.Update(entity);
            dataSet.Commit();

            // Assert

            dataSet.Inserts.Should().Be(0);
            dataSet.Deletes.Should().Be(0);
            dataSet.Updates.Should().Be(1);

            dataSet.Rollback();

            dataSet.Inserts.Should().Be(0);
            dataSet.Deletes.Should().Be(0);
            dataSet.Updates.Should().Be(2);

            var operation = dataSet.InternalOperations.Single();

            operation.CurrentEntity.Should().Not.Be.EqualTo(operation.PreviousEntity);
        }
コード例 #6
0
        public void Rollback_PassingDoRollbackFalseInConstructor_ShouldNotRollbackTheOperations(
            object entity)
        {
            // Arrange

            var dataSet = new FakeDataSet<object>(false);

            // Act

            dataSet.Insert(entity);
            dataSet.Delete(entity);
            dataSet.Update(entity);

            dataSet.Commit();
            dataSet.Rollback();

            // Assert

            dataSet.Inserts.Should().Be(1);
            dataSet.Deletes.Should().Be(1);
            dataSet.Updates.Should().Be(1);
        }