예제 #1
0
        public void Unregister_CorrectWorkflow()
        {
            var mock1    = new Mock <IUnitOfWork>();
            var mock2    = new Mock <IUnitOfWork>();
            var registry = new UnitOfWorkRegistry();

            registry.Register(mock1.Object);
            registry.Register(mock2.Object);

            registry.Unregister(mock2.Object);
            registry.Unregister(mock1.Object);
            Assert.IsNull(registry.GetCurrent());
        }
예제 #2
0
        public void Unregister_UnexistingUoW_ThrowsException()
        {
            var mock1    = new Mock <IUnitOfWork>();
            var registry = new UnitOfWorkRegistry();

            registry.Unregister(mock1.Object);
        }
예제 #3
0
        private Task WorkForAsyncOperations_asyncOperation(UnitOfWorkRegistry registry)
        {
            var mock2 = new Mock <IUnitOfWork>();

            registry.Register(mock2.Object);
            Assert.AreEqual(mock2.Object, registry.GetCurrent());

            registry.Unregister(mock2.Object);
            return(Task.FromResult(true));
        }
예제 #4
0
        public void Unregister_WrongOrder_ThrowsException()
        {
            var mock1    = new Mock <IUnitOfWork>();
            var mock2    = new Mock <IUnitOfWork>();
            var registry = new UnitOfWorkRegistry();

            registry.Register(mock1.Object);
            registry.Register(mock2.Object);

            registry.Unregister(mock1.Object);
        }
예제 #5
0
        public async Task WorkForAsyncOperations()
        {
            var mock1    = new Mock <IUnitOfWork>();
            var registry = new UnitOfWorkRegistry();

            registry.Register(mock1.Object);

            Assert.AreEqual(mock1.Object, registry.GetCurrent());
            await WorkForAsyncOperations_asyncOperation(registry);

            Assert.AreEqual(mock1.Object, registry.GetCurrent());
            registry.Unregister(mock1.Object);

            Assert.IsNull(registry.GetCurrent());
        }