Beispiel #1
0
        public void RemoveRegistrationDependency()
        {
            var fakeOracleDependencyManager = A.Fake <IOracleDependencyManager>();
            var fakeOracleDependencyManagerRegistryDepCall = A.CallTo(() => fakeOracleDependencyManager.RegisterDependency(null)).WithAnyArguments();

            var fakeOracleDependencyManagerRemoveRegistrationCall =
                A.CallTo(() => fakeOracleDependencyManager.RemoveRegistration(string.Empty)).WithAnyArguments();

            var fakeSignalrDbDependencyFactory = A.Fake <ISignalrDbDependencyFactory>();
            var fakeSignalrDbDependencyFactoryCreateDepCall = A.CallTo(() => fakeSignalrDbDependencyFactory.CreateDbDependency(null, false, 0, false)).WithAnyArguments();

            var fakeSignalrDependency = new FakeSignalrDependency();

            fakeSignalrDbDependencyFactoryCreateDepCall.Returns(fakeSignalrDependency);

            ObservableDbOperation dbOperation = new ObservableDbOperation(string.Empty, string.Empty, new TraceSource("ss"),
                                                                          null,
                                                                          A.Fake <IDbProviderFactory>(),
                                                                          fakeOracleDependencyManager,
                                                                          fakeSignalrDbDependencyFactory,
                                                                          true);

            dbOperation.ExecuteReaderWithUpdates(A.Fake <Action <IDataRecord, IDbOperation> >());

            fakeSignalrDependency.FireEvent(OracleNotificationType.Subscribe, OracleNotificationInfo.Error);

            fakeOracleDependencyManagerRegistryDepCall.MustHaveHappened(Repeated.Exactly.Once);
            fakeSignalrDbDependencyFactoryCreateDepCall.MustHaveHappened(Repeated.Exactly.Once);
            fakeOracleDependencyManagerRemoveRegistrationCall.MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #2
0
        public void DependencyFault()
        {
            var fakeOracleDependencyManager = A.Fake <IOracleDependencyManager>();
            var fakeOracleDependencyManagerRegistryDepCall = A.CallTo(() => fakeOracleDependencyManager.RegisterDependency(null)).WithAnyArguments();

            var fakeSignalrDbDependencyFactory = A.Fake <ISignalrDbDependencyFactory>();
            var fakeSignalrDbDependencyFactoryCreateDepCall = A.CallTo(() => fakeSignalrDbDependencyFactory.CreateDbDependency(null, false, 0, false)).WithAnyArguments();

            var fakeSignalrDependency = new FakeSignalrDependency();

            fakeSignalrDbDependencyFactoryCreateDepCall.Returns(fakeSignalrDependency);

            ObservableDbOperation dbOperation = new ObservableDbOperation(string.Empty, string.Empty, new TraceSource("ss"),
                                                                          null,
                                                                          A.Fake <IDbProviderFactory>(),
                                                                          fakeOracleDependencyManager,
                                                                          fakeSignalrDbDependencyFactory,
                                                                          true);

            dbOperation.ExecuteReaderWithUpdates(A.Fake <Action <IDataRecord, IDbOperation> >());

            int faultCounter = 0;

            dbOperation.Faulted += ex => { if (ex != null)
                                           {
                                               faultCounter++;
                                           }
            };

            fakeSignalrDependency.FireEvent(OracleNotificationType.Change, OracleNotificationInfo.Error);

            Assert.AreEqual(1, faultCounter);
            fakeOracleDependencyManagerRegistryDepCall.MustHaveHappened(Repeated.Exactly.Once);
            fakeSignalrDbDependencyFactoryCreateDepCall.MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #3
0
        public void UpdateDependency()
        {
            var fakeOracleDependencyManager = A.Fake <IOracleDependencyManager>();
            var fakeOracleDependencyManagerRegistryDepCall =
                A.CallTo(() => fakeOracleDependencyManager.RegisterDependency(null)).WithAnyArguments();

            var fakeSignalrDbDependencyFactory = A.Fake <ISignalrDbDependencyFactory>();
            var fakeSignalrDbDependencyFactoryCreateDepCall =
                A.CallTo(() => fakeSignalrDbDependencyFactory.CreateDbDependency(null, false, 0, false))
                .WithAnyArguments();

            var fakeSignalrDependency = new FakeSignalrDependency();

            fakeSignalrDbDependencyFactoryCreateDepCall.Returns(fakeSignalrDependency);

            TraceSource       trace        = new TraceSource("Fault");
            FakeTraceListener fakeListener = new FakeTraceListener();

            trace.Listeners.Add(fakeListener);
            trace.Switch.Level = SourceLevels.All;

            ObservableDbOperation dbOperation = new ObservableDbOperation(string.Empty, string.Empty, trace,
                                                                          null,
                                                                          A.Fake <IDbProviderFactory>(),
                                                                          fakeOracleDependencyManager,
                                                                          fakeSignalrDbDependencyFactory,
                                                                          true);

            dbOperation.ExecuteReaderWithUpdates(A.Fake <Action <IDataRecord, IDbOperation> >());
            fakeSignalrDependency.FireEvent(OracleNotificationType.Change, OracleNotificationInfo.Update);
            int counter = 0;

            dbOperation.Faulted += (ex) => { counter++; };
            Assert.AreEqual(0, counter);
            Assert.IsTrue(fakeListener.Traces.Exists(item => item.StartsWith("Oracle notification details:")));

            fakeSignalrDependency.FireEvent(OracleNotificationType.Change, OracleNotificationInfo.End);
            Assert.AreEqual(0, counter);
            Assert.IsTrue(fakeListener.Traces.Exists(item => item.StartsWith("Oracle notification timed out")));

            fakeSignalrDependency.FireEvent(OracleNotificationType.Change, OracleNotificationInfo.Drop);
            Assert.AreEqual(1, counter);
            Assert.IsTrue(fakeListener.Traces.Exists(item => item.StartsWith("Unexpected Oracle notification details:")));

            fakeOracleDependencyManagerRegistryDepCall.MustHaveHappened(Repeated.AtLeast.Once);
            fakeSignalrDbDependencyFactoryCreateDepCall.MustHaveHappened(Repeated.AtLeast.Once);
        }