Beispiel #1
0
        public override void Close()
        {
            Flush();

            base.Close();

            if (_canClose)
            {
                try {
                    CloseSite.Target(CloseSite, _io);
                } catch (MissingMethodException) {
                    // nop
                }
            }
        }
Beispiel #2
0
        public void Should_throw_exception_when_site_is_not_found()
        {
            var command = new CloseSite
            {
                Id = Guid.NewGuid()
            };

            var repositoryMock = new Mock <ISiteRepository>();

            repositoryMock.Setup(x => x.GetById(command.Id)).Returns((Site)null);

            var closeSiteHandler = new CloseSiteHandler(repositoryMock.Object);

            Assert.Throws <Exception>(() => closeSiteHandler.Handle(command));
        }
Beispiel #3
0
        public void Should_update_site()
        {
            var command = new CloseSite
            {
                Id = Guid.NewGuid()
            };

            var siteMock = new Mock <Site>();

            var repositoryMock = new Mock <ISiteRepository>();

            repositoryMock.Setup(x => x.GetById(command.Id)).Returns(siteMock.Object);

            var closeSiteHandler = new CloseSiteHandler(repositoryMock.Object);

            closeSiteHandler.Handle(command);

            repositoryMock.Verify(x => x.Update(It.IsAny <Site>()));
        }
Beispiel #4
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Flush();

                base.Dispose(disposing);

                if (_canClose)
                {
                    try {
                        CloseSite.Target(CloseSite, _io);
                    } catch (MissingMethodException) {
                        // nop
                    }
                }
            }
            else
            {
                base.Dispose(disposing);
            }
        }