Ejemplo n.º 1
0
        public void Prepare_InsertsEvents(
            [Frozen] Mock <IBatchOperation> operationMock,
            [Frozen] string streamName,
            [Frozen] EventStreamHeader header,
            JournaledEvent[] events,
            AppendOperation operation)
        {
            operation.Prepare(events);

            var version = header.Version;

            foreach (var journaledEvent in events)
            {
                var e = journaledEvent;
                version = version.Increment();

                VerifyInsertOperation(
                    operationMock: operationMock,
                    partitionKey: streamName,
                    rowKey: version.ToString(),
                    verifyColumns: columns =>
                    columns["EventId"].Equals(e.EventId) &&
                    columns["EventType"].Equals(e.EventTypeName));
            }
        }
Ejemplo n.º 2
0
        public void Prepare_CreatesBatchOperation(
            [Frozen] Mock <ICloudTable> tableMock,
            JournaledEvent[] events,
            AppendOperation operation)
        {
            operation.Prepare(events);

            tableMock.Verify(self => self.PrepareBatchOperation(), Times.Once());
        }
Ejemplo n.º 3
0
        public async Task Execute_ReturnsHeaderWithNewETag(
            [Frozen] IReadOnlyList <OperationResult> batchResult,
            JournaledEvent[] events,
            AppendOperation operation)
        {
            operation.Prepare(events);

            var result = await operation.ExecuteAsync();

            Assert.Equal(batchResult[0].ETag, result.ETag);
        }
Ejemplo n.º 4
0
        public async Task Execute_ReturnsHeaderWithIncrementedVersion(
            [Frozen] StreamVersion currentVersion,
            JournaledEvent[] events,
            AppendOperation operation)
        {
            var targetVersion = currentVersion.Increment(events.Count());

            operation.Prepare(events);

            var result = await operation.ExecuteAsync();

            Assert.Equal(targetVersion, result.Version);
        }
Ejemplo n.º 5
0
        public void Prepare_ForUnknownHeader_InsertsHeaderRow(
            [Frozen] Mock <IBatchOperation> operationMock,
            [Frozen] string streamName,
            [Frozen] EventStreamHeader header,
            JournaledEvent[] events,
            AppendOperation operation)
        {
            var targetVersion = (int)header.Version.Increment(events.Count());

            operation.Prepare(events);

            VerifyInsertOperation(
                operationMock,
                streamName,
                "HEAD",
                name => name.Equals("Version"),
                value => value.Equals(targetVersion));
        }