Пример #1
0
        public void Unregister_UnexistingUoW_ThrowsException()
        {
            var mock1    = new Mock <IUnitOfWork>();
            var registry = new UnitOfWorkRegistry();

            registry.Unregister(mock1.Object);
        }
Пример #2
0
        public void GetCurrent_withoutRegisteredReturnsNull()
        {
            var registry = new UnitOfWorkRegistry();

            Assert.IsNull(registry.GetCurrent());
            Assert.IsNull(registry.GetCurrent(1));
            Assert.IsNull(registry.GetCurrent(2));
        }
Пример #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 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());
        }
Пример #6
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());
        }
Пример #7
0
        public void Register_asDefaultReturnsLastUnitOfWOrk()
        {
            var mock1    = new Mock <IUnitOfWork>();
            var mock2    = new Mock <IUnitOfWork>();
            var registry = new UnitOfWorkRegistry();

            registry.Register(mock1.Object);
            Assert.AreEqual(mock1.Object, registry.GetCurrent());
            Assert.IsNull(registry.GetCurrent(1));

            registry.Register(mock2.Object);
            Assert.AreEqual(mock2.Object, registry.GetCurrent());
            Assert.AreEqual(mock1.Object, registry.GetCurrent(1));
            Assert.IsNull(registry.GetCurrent(2));
        }