public void CanReleaseAfterAquire() { var esClient = Substitute.For<IElasticClient>(); esClient.Delete("", "", "").ReturnsForAnyArgs(call => { var response = Substitute.For<IDeleteResponse>(); response.IsValid.Returns(true); return response; }); esClient.Update<object>(u => u.Script("")).ReturnsForAnyArgs(call => { var response = Substitute.For<IUpdateResponse>(); response.IsValid.Returns(true); return response; }); var dLock = new ElasticSearchDistributedLock("Test", esClient); Assert.IsTrue(dLock.Aquire()); Assert.IsTrue(dLock.Release()); }
public void CanReleaseWithoutAquire() { var esClient = Substitute.For<IElasticClient>(); var dLock = new ElasticSearchDistributedLock("Test", esClient); Assert.IsTrue(dLock.Release()); }