Skip to content

Commit

Permalink
Merge branch 'master' into users/sakulk/checkKeyVaultUri
Browse files Browse the repository at this point in the history
  • Loading branch information
kr-santosh authored Jan 16, 2023
2 parents 4618dd7 + 36d0e0f commit 80ce3e4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public DateTime? StartTime
throw new ArgumentException("StartTime cannot have DateTimeKind.Unspecified", nameof(value));
}

this.startTime = value;
this.startTime = value.HasValue && value.Value.Kind == DateTimeKind.Local ? value.Value.ToUniversalTime() : value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,41 @@ public void CanBuildWithInMemoryContainer()
Assert.IsInstanceOfType(builder.Build(), typeof(ChangeFeedProcessor));
}

[TestMethod]
public void ConvertsToUTC()
{
DateTime localTime = DateTime.Now;

Assert.AreEqual(DateTimeKind.Local, localTime.Kind);

Action<DocumentServiceLeaseStoreManager,
Container,
string,
ChangeFeedLeaseOptions,
ChangeFeedProcessorOptions,
Container> verifier = (DocumentServiceLeaseStoreManager leaseStoreManager,
Container leaseContainer,
string instanceName,
ChangeFeedLeaseOptions changeFeedLeaseOptions,
ChangeFeedProcessorOptions changeFeedProcessorOptions,
Container monitoredContainer) =>
{
Assert.AreEqual(DateTimeKind.Utc, changeFeedProcessorOptions.StartTime.Value.Kind);
Assert.AreEqual(localTime.ToUniversalTime(), changeFeedProcessorOptions.StartTime.Value);
};

ChangeFeedProcessorBuilder builder = new ChangeFeedProcessorBuilder("workflowName",
ChangeFeedProcessorBuilderTests.GetMockedContainer(),
ChangeFeedProcessorBuilderTests.GetMockedProcessor(),
verifier);

builder.WithLeaseContainer(ChangeFeedProcessorBuilderTests.GetMockedContainer());

builder.WithStartTime(localTime);

Assert.IsInstanceOfType(builder.Build(), typeof(ChangeFeedProcessor));
}

private static ContainerInternal GetMockedContainer(string containerName = null)
{
Mock<ContainerInternal> mockedContainer = MockCosmosUtil.CreateMockContainer(containerName: containerName);
Expand Down

0 comments on commit 80ce3e4

Please sign in to comment.