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

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

            dataSet.Rollback();

            // Assert

            dataSet.Inserts.Should().Be(0);
            dataSet.Deletes.Should().Be(0);
            dataSet.Updates.Should().Be(0);
        }
コード例 #2
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);
        }
コード例 #3
0
        public void Insert_WithCommit_ShouldChangeOperationTypeToDeleteAndSetAsDone(
            object entity,
            FakeDataSet<object> dataSet)
        {
            // Act

            dataSet.Insert(entity);
            dataSet.Commit();

            // Assert

            var operation = dataSet.InternalOperations.Single();

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

            dataSet.Insert(entity);

            // Assert

            var operation = dataSet.InternalOperations.Single();

            operation.CurrentEntity.Should().Be.EqualTo(entity);
            operation.Type.Should().Be(BaseDataSetOperationType.Insert);
            operation.Done.Should().Be.False();
        }
コード例 #5
0
        public void Insert_WithCommitAndRollback_ShouldInsertAfterCommitAndDeleteAfterRollback(
            object entity,
            FakeDataSet<object> dataSet)
        {
            // Act

            dataSet.Insert(entity);
            dataSet.Commit();

            // Assert

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

            dataSet.Rollback();

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