public async void GetOrCreateAsyncTest3() { var context = new MockContext <IEndpoint>(); context.Arrange(m => m.List("domainId", The <EndpointQuery> .IsAnyValue, null)).Returns(new Endpoint[0]); context.Arrange(m => m.CreateAsync(The <CreateEndpointData> .Is(d => d.Name == "endpoint" && d.ApplicationId == "appId" && d.DomainId == "domainId"), null)).Returns(Task.FromResult("endpointId4")); context.Arrange(m => m.GetAsync("domainId", "endpointId4", null)).Returns(Task.FromResult(new Endpoint { Id = "endpointId4", Name = "endpoint" })); var endpoint = new MockEndpoint(context); var item = await endpoint.GetOrCreateAsync("appId", "domainId", "endpoint"); Assert.Equal("endpointId4", item.Id); }
public async void GetOrCreateAsyncTest() { var context = new MockContext <IEndpoint>(); context.Arrange(m => m.List("domainId", The <EndpointQuery> .IsAnyValue, null)).Returns(new [] { new Endpoint { Id = "endpointId2", Name = "endpoint" } }); var endpoint = new MockEndpoint(context); var item = await endpoint.GetOrCreateAsync(new CreateEndpointData { Name = "endpoint", ApplicationId = "appId", DomainId = "domainId" }); Assert.Equal("endpointId2", item.Id); }