public async Task DataContext_FindAsync_ThrowsExceptionWhenRecordDoesNotExist()
        {
            var bookTable = Context.GetTable <Book>();

            await Should.ThrowAsync <InvalidOperationException>(() => bookTable.FindAsync(Guid.NewGuid().ToString(), 0));
        }
Ejemplo n.º 2
0
        public void Get_CallsRepository_InvalidIdIsPassedToRepository_BadRequestExceptionIsThrown()
        {
            var assesmentEventDomain = new AssessmentEventDomain(null);

            Should.ThrowAsync <BadRequestException>(() => assesmentEventDomain.GetAsync(-1));
        }
Ejemplo n.º 3
0
 public async Task GetXmltvAsync_Not_Throw_InvalidXtreamUrlFormatException(string url)
 {
     var xtreamClient = new XtreamClient(DefaultHttpClientFactory.Default);
     await Should.ThrowAsync <HttpRequestException>(xtreamClient.GetXmltvAsync(new XtUrlConnectionFactory(url).Create(), CancellationToken.None));
 }
Ejemplo n.º 4
0
        public async Task TryModifyAsync_CriteriaIsInvalid_Throws(ulong guildId, string name, ulong modifiedByUserId, Action <TagMutationData> modifyAction, Type exceptionType)
        {
            (var modixContext, var uut) = BuildTestContext();

            await Should.ThrowAsync(() => uut.TryModifyAsync(guildId, name, modifiedByUserId, modifyAction), exceptionType);
        }
Ejemplo n.º 5
0
 public async Task ShouldNotGetByUrlAsync()
 {
     await Should.ThrowAsync <Exception>(async() => await _pageAppService.GetByUrlAsync("not-exist-url"));
 }
Ejemplo n.º 6
0
 public async Task Should_throw_for_void_send()
 {
     await Should.ThrowAsync <InvalidOperationException>(async() => await _mediator.Send(new VoidPing()));
 }
Ejemplo n.º 7
0
        public async Task ShouldDeleteAsync()
        {
            await _pageAdminAppService.DeleteAsync(_data.Page_1_Id);

            await Should.ThrowAsync <Exception>(async() => await _pageRepository.GetAsync(_data.Page_1_Id));
        }
Ejemplo n.º 8
0
        public async Task IChannelStreamingProducer_Test_64_ChannelData_Returned_For_StreamingStartIndex_With_IndexValue()
        {
            await RequestSessionAndAssert();

            var handler = _client.Handler <IChannelStreamingConsumer>();
            var channelStreamingInfos = new List <ChannelStreamingInfo>();

            // Compose Uris for one channel from each pre-loaded log
            var uris = new List <string>
            {
                TestUris.LogMd.Append("logCurveInfo", "ROPI"),
                TestUris.LogMdDec.Append("logCurveInfo", "PESD"),
                TestUris.LogTime.Append("logCurveInfo", "GS_TV08"),
                TestUris.LogTimeDec.Append("logCurveInfo", "GS_TV06")
            };

            // Register event handlers
            var onChannelMetadata = HandleMultiPartAsync <ChannelMetadata>(x => handler.OnChannelMetadata += x);
            var onChannelData     = HandleMultiPartAsync <ChannelData>(x => handler.OnChannelData += x, uris.Count);

            // Send Start message
            handler.Start();

            // Request ChannelMetadata
            var messageId = handler.ChannelDescribe(uris);

            // Wait for ChannelMetadata message
            var argsMetadata = await onChannelMetadata;

            // Verify ChannelMetadata
            var channels = VerifyChannelMetadata(argsMetadata, uris, messageId);

            // Get channels by mnemonic for inspection
            var channelRopi  = channels.FirstOrDefault(c => c.ChannelName.Equals("ROPI"));
            var channelPesd  = channels.FirstOrDefault(c => c.ChannelName.Equals("PESD"));
            var channelGstv8 = channels.FirstOrDefault(c => c.ChannelName.Equals("GS_TV08"));
            var channelGstv6 = channels.FirstOrDefault(c => c.ChannelName.Equals("GS_TV06"));

            channelStreamingInfos.Add(ToChannelStreamingInfo(channelRopi, ToScale(channelRopi, 4342.181)));
            channelStreamingInfos.Add(ToChannelStreamingInfo(channelPesd, ToScale(channelPesd, 3437.839)));
            channelStreamingInfos.Add(ToChannelStreamingInfo(channelGstv8, ToMicroseconds("2015-11-22T10:49:45.0000000+00:00")));
            channelStreamingInfos.Add(ToChannelStreamingInfo(channelGstv6, ToMicroseconds("2015-11-29T15:28:25.0000000+00:00")));

            // Send ChannelStreamingStart message
            handler.ChannelStreamingStart(channelStreamingInfos);

            // Wait for ChannelData messages
            var argsData = await onChannelData;

            Assert.IsNotNull(argsData);

            // Verify that at least 4 ChannelData messages are received, at least one for each log channel.
            Assert.IsTrue(argsData.Count >= 4);

            foreach (var arg in argsData)
            {
                // Verify for each ChannelData message that the correlationId is 0.
                VerifyCorrelationId(arg, 0);

                var messageData = arg.Message.Data;
                var channelId   = messageData.Select(d => d.ChannelId).FirstOrDefault();

                // Verify that 10 data points are received for each log channel....
                Assert.AreEqual(10, messageData.Count, $"The Message does not have the expected number of data points for channelId {channelId}.");

                //... with no duplication...
                var dupCount = messageData.GroupBy(c => c.Indexes.FirstOrDefault()).Count(grp => grp.Count() > 1);
                Assert.AreEqual(0, dupCount);

                // Get data to verify index order.
                var channelMetadata = channels.FirstOrDefault(c => c.ChannelId.Equals(channelId));
                Assert.IsNotNull(channelMetadata);

                var indexMetadata = channelMetadata.Indexes.FirstOrDefault();
                Assert.IsNotNull(indexMetadata);

                var indexes = messageData.Select(d => d.Indexes.FirstOrDefault()).ToArray();

                //... and in index order.
                VerifyIndexOrder(indexes, indexMetadata.Direction == IndexDirections.Increasing);
            }

            // Isolate data by channel
            var channelRopiData  = GetChannelData(argsData, channelRopi.ChannelId);
            var channelPesdData  = GetChannelData(argsData, channelPesd.ChannelId);
            var channelGstv8Data = GetChannelData(argsData, channelGstv8.ChannelId);
            var channelGstv6Data = GetChannelData(argsData, channelGstv6.ChannelId);

            // Verify that the 10 data points are the "last" 10 points in each log channel
            //... by checking the last index value
            VerifyDataIndexValue(channelRopiData, channelRopiData.Length - 1, ToScale(channelRopi, 4343.705));
            VerifyDataIndexValue(channelPesdData, channelPesdData.Length - 1, ToScale(channelPesd, 3080.614));
            VerifyDataIndexValue(channelGstv8Data, channelGstv8Data.Length - 1, ToMicroseconds("2015-11-22T10:50:03.0000000+00:00"));
            VerifyDataIndexValue(channelGstv6Data, channelGstv6Data.Length - 1, ToMicroseconds("2015-11-29T15:28:07.0000000+00:00"));

            // Wait 30s and verify that no further ChannelData messages are sent.
            var onMoreChannelData = HandleMultiPartAsync <ChannelData>(x => handler.OnChannelData += x, 1, 30000);

            // Assert a Timeout exception because no data should be returned within 30s
            await Should.ThrowAsync <TimeoutException>(onMoreChannelData);
        }
Ejemplo n.º 9
0
 public async Task FetchDataFromUrl_ShouldThrowExceptionIfInvalidUrl()
 {
     await Should.ThrowAsync <Exception>(_fetchDataService.FetchOrderBookDataFromUrl("test"));
 }
Ejemplo n.º 10
0
        public async Task Should_throw_with_enumerable_query_scalar()
        {
            var exception = await Should.ThrowAsync <InvalidOperationException>(() => _queryable.AverageAsync()).ConfigureAwait(false);

            exception.Message.ShouldBe("The provider for the source IQueryable doesn't implement IAsyncRemoteQueryProvider. Only providers implementing Remote.Linq.IAsyncRemoteQueryProvider can be used for Remote Linq asynchronous operations.");
        }
Ejemplo n.º 11
0
 public async Task web_exception_thrown_when_user_not_found()
 {
     await Should.ThrowAsync <WebException>(async() =>
                                            await _userInformation.Get("ofksofs"));
 }
Ejemplo n.º 12
0
 public void SetTrainingState_WhenDataCollectorDoesNotExist_ShouldThrowException()
 {
     Should.ThrowAsync <Exception>(() => _dataCollectorService.SetTrainingState(3, true));
 }
Ejemplo n.º 13
0
 public void GetDataCollector_WhenDataCollectorDoesNotExist_ShouldThrowException()
 {
     Should.ThrowAsync <Exception>(() => _dataCollectorService.Get(3));
 }
Ejemplo n.º 14
0
        public async Task Response_ShouldThrowException()
        {
            var request = new TestWithExceptionAsyncRequest(Guid.NewGuid());

            await Should.ThrowAsync <NotImplementedException>(async() => await mediator.GetAsync(request));
        }
Ejemplo n.º 15
0
 public static async Task ShouldNotAuthorize <TResult>(
     this ITestFixture _,
     IRequest <TResult> request)
 {
     await Should.ThrowAsync <UnauthorizedException>(async() => await _.Send(request));
 }
 public async Task send_message_with_no_known_subscribers()
 {
     buildHost();
     await Should.ThrowAsync <NoRoutesException>(async() =>
                                                 await theHost.Get <IMessagePublisher>().Send(new Message3()));
 }
Ejemplo n.º 17
0
 public async Task web_exception_thrown_when_one_not_user()
 {
     await Should.ThrowAsync <WebException>(async() =>
                                            await _compareUsersFollowers.GetCommonFollowersListAsync(_firstUser, "ofksofs"));
 }
 public async Task RequiresRequestServices_TSource_and_TReturn()
 {
     var resolver = new ScopedFieldResolver <string, int>(context => 5);
     await Should.ThrowAsync <MissingRequestServicesException>(async() => await resolver.ResolveAsync(new ResolveFieldContext()).ConfigureAwait(false)).ConfigureAwait(false);
 }
Ejemplo n.º 19
0
        public async Task NullRequestServicesThrows()
        {
            var e = await Should.ThrowAsync <ArgumentNullException>(async() => await new DIDocumentExecuter().ExecuteAsync(new ExecutionOptions()));

            e.ParamName.ShouldBe("options.RequestServices");
        }
Ejemplo n.º 20
0
        public async Task Should_throw_when_calling_single_or_default_with_predicate_on_query_with_multiple_results_async()
        {
            var ex = await Should.ThrowAsync <InvalidOperationException>(() => _queryable.SingleOrDefaultAsync(x => x.Value.ToUpper().Contains("O"))).ConfigureAwait(false);

            ex.Message.ShouldBe("Sequence contains more than one matching element");
        }
Ejemplo n.º 21
0
        public async Task TryIncrementUsesAsync_CriteriaIsInvalid_Throws(ulong guildId, string name, Type exceptionType)
        {
            (var modixContext, var uut) = BuildTestContext();

            await Should.ThrowAsync(() => uut.TryIncrementUsesAsync(guildId, name), exceptionType);
        }
 public override Task <GetSwiftException> ActAsync()
 {
     return(Should.ThrowAsync <GetSwiftException>(() => Service.CreateAsync(Input)));
 }
Ejemplo n.º 23
0
        public async Task TryDeleteAsync_CriteriaIsInvalid_Throws(ulong guildId, string name, ulong deletedByUserId, Type exceptionType)
        {
            (var modixContext, var uut) = BuildTestContext();

            await Should.ThrowAsync(() => uut.TryDeleteAsync(guildId, name, deletedByUserId), exceptionType);
        }
        public async Task Should_throw_upon_calling_ToArrayAsync_on_remote_stream_queryable()
        {
            var ex = await Should.ThrowAsync <NotSupportedException>(async() => await AsyncRemoteStreamQueryable.ToArrayAsync());

            ex.Message.ShouldBe(MustBeExecutedAsAsyncEnumerable);
        }
Ejemplo n.º 25
0
 public async Task ExceptionIsThrown()
 {
     await Should.ThrowAsync <PublishException>(() => SystemUnderTest.PublishAsync(new SimpleMessage()));
 }
Ejemplo n.º 26
0
 public async Task Should_throw_for_void_send()
 {
     await Should.ThrowAsync <StructureMapConfigurationException>(async() => await _mediator.Send(new VoidPing()));
 }
Ejemplo n.º 27
0
 protected Task <Exception> RunTestAndExpectThrow(Func <TOrmContext, Task> test)
 => Should.ThrowAsync(() => RunTest(test));
Ejemplo n.º 28
0
    public async Task ShouldDelete_WithRepliesAsync()
    {
        await _commentAdminAppService.DeleteAsync(_cmsKitTestData.CommentWithChildId);

        await Should.ThrowAsync <EntityNotFoundException>(async() => await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId));
    }
Ejemplo n.º 29
0
 public async Task GetXmltvAsync_BasicAuth_Not_Throw_InvalidXtreamUrlFormatException(string server, string username, string password)
 {
     var xtreamClient = new XtreamClient(DefaultHttpClientFactory.Default);
     await Should.ThrowAsync <HttpRequestException>(xtreamClient.GetXmltvAsync(new XtBasicConnectionFactory(server, username, password).Create(), CancellationToken.None));
 }
 public void NegativeLegalPartyRoleIdInList_BadRequestException()
 {
     Should.ThrowAsync <BadRequestException>(async() => { await _legalPartyOfficialDocumentDomain.ListAsync(new List <int> {
             -5
         }, DateTime.Now); });
 }