Exemplo n.º 1
0
        public async void GetOrCreateTollFreeAsyncTest2()
        {
            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.GetOrCreateTollFreeAsync(new MockAvailableNumber(availableNumberContext), "appId", "name", null);

            Assert.Equal("+1234567891", number);
        }
Exemplo n.º 2
0
        public async void GetOrCreateTollFreeAsyncTest()
        {
            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.SearchAndOrderTollFreeAsync(The <TollFreeNumberQueryForOrder> .Is(q => 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.GetOrCreateTollFreeAsync(new MockAvailableNumber(availableNumberContext), "appId", "name", null);

            Assert.Equal("+1234567890", number);
        }