public override void Close() { Flush(); base.Close(); if (_canClose) { try { CloseSite.Target(CloseSite, _io); } catch (MissingMethodException) { // nop } } }
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)); }
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>())); }
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); } }