Пример #1
0
        public void AdvanceClusterTime_should_advance_both_cluster_clocks()
        {
            var mockWrapped      = new Mock <ICoreSession>();
            var mockClusterClock = new Mock <IClusterClock>();
            var subject          = new ClusterClockAdvancingCoreSession(mockWrapped.Object, mockClusterClock.Object);
            var newClusterTime   = new BsonDocument("clusterTime", new BsonTimestamp(1L));

            subject.AdvanceClusterTime(newClusterTime);

            mockWrapped.Verify(m => m.AdvanceClusterTime(newClusterTime), Times.Once);
            mockClusterClock.Verify(m => m.AdvanceClusterTime(newClusterTime), Times.Once);
        }
Пример #2
0
        public void constructor_should_initialize_instance()
        {
            var wrapped      = new Mock <ICoreSession>().Object;
            var clusterClock = new Mock <IClusterClock>().Object;

            var result = new ClusterClockAdvancingCoreSession(wrapped, clusterClock);

            result.Wrapped.Should().BeSameAs(wrapped);
            result.IsDisposed().Should().BeFalse();
            result._clusterClock().Should().BeSameAs(clusterClock);
            result._ownsWrapped().Should().BeFalse();
        }
Пример #3
0
        public void ClusterTime_should_return_the_greater_of_the_session_and_cluster_cluster_times(long sessionTimestamp, long clusterTimestamp, long expectedTimestamp)
        {
            var sessionClusterTime = new BsonDocument("clusterTime", new BsonTimestamp(sessionTimestamp));
            var clusterClusterTime = new BsonDocument("clusterTime", new BsonTimestamp(clusterTimestamp));
            var expectedResult     = new BsonDocument("clusterTime", new BsonTimestamp(expectedTimestamp));
            var mockSession        = new Mock <ICoreSession>();

            mockSession.SetupGet(m => m.ClusterTime).Returns(sessionClusterTime);
            var mockClusterClock = new Mock <IClusterClock>();

            mockClusterClock.SetupGet(m => m.ClusterTime).Returns(clusterClusterTime);
            var subject = new ClusterClockAdvancingCoreSession(mockSession.Object, mockClusterClock.Object);

            var result = subject.ClusterTime;

            result.Should().Be(expectedResult);
        }
Пример #4
0
        public static IClusterClock _clusterClock(this ClusterClockAdvancingCoreSession obj)
        {
            var fieldInfo = typeof(ClusterClockAdvancingCoreSession).GetField("_clusterClock", BindingFlags.NonPublic | BindingFlags.Instance);

            return((IClusterClock)fieldInfo.GetValue(obj));
        }