public async void GetOrCreateLocalAsyncTest() { var context = new MockContext <IPhoneNumber>(); var availableNumberContext = new MockContext <IAvailableNumber>(); context.Arrange(m => m.List(The <PhoneNumberQuery> .Is(q => q.Size.Value == 1000 && q.ApplicationId == "appId" && q.Name == "name"), null)).Returns(new PhoneNumber[0]); context.Arrange(m => m.UpdateAsync("phoneNumberId", The <UpdatePhoneNumberData> .Is(d => d.ApplicationId == "appId" && d.Name == "name"), null)).Returns(Task.FromResult(0)); availableNumberContext.Arrange(m => m.SearchAndOrderLocalAsync(The <LocalNumberQueryForOrder> .Is(q => q.AreaCode == "910" && q.Quantity.Value == 1), null)).Returns(Task.FromResult( new[] { new OrderedNumber { Number = "+1234567890", Location = "http://lovalhost/phoneNumberId" } } )); var phoneNumber = new MockPhoneNumber(context); var number = await phoneNumber.GetOrCreateLocalAsync(new MockAvailableNumber(availableNumberContext), "appId", new LocalNumberQueryForOrder { AreaCode = "910" }, "name", null); Assert.Equal("+1234567890", number); }
public async void GetOrCreateLocalAsyncTest2() { var context = new MockContext <IPhoneNumber>(); var availableNumberContext = new MockContext <IAvailableNumber>(); context.Arrange(m => m.List(The <PhoneNumberQuery> .Is(q => q.Size.Value == 1000 && q.ApplicationId == "appId" && q.Name == "name"), null)).Returns(new [] { new PhoneNumber { Number = "+1234567891" } }); var phoneNumber = new MockPhoneNumber(context); var number = await phoneNumber.GetOrCreateLocalAsync(new MockAvailableNumber(availableNumberContext), "appId", new LocalNumberQueryForOrder { AreaCode = "910" }, "name", null); Assert.Equal("+1234567891", number); }