示例#1
0
        public void ShouldSearchWithNoSpecifiedResultSize()
        {
            var param = SearchParameter.CreateForAddress(AccountAddress1).Build();

            var result = UnitUnderTest.Search(param);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreEqual(result.Results.Count, 10);
        }
        public void ShouldSearchWithAccountAddress()
        {
            var param = SearchParameter.CreateForAddress(AccountAddress1).Build();

            var result = UnitUnderTest.Search(param);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreEqual(result.Results.Count, 10);
            Assert.IsNotNull(result.ToTransactionId);
            Assert.IsNull(result.FromTransactionId);
        }
        public void ShouldSearchAllTransactions()
        {
            var param = SearchParameter.CreateForAddress(AccountAddress1)
                        .WithTransactionFilter(TransactionFilter.All)
                        .Build();

            var result = UnitUnderTest.Search(param);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreEqual(result.Results.Count, 10);
        }
示例#4
0
        public void ShouldSearchAsynchronouslyWithoutCallback()
        {
            var param = SearchParameter.CreateForAddress(AccountAddress1).Build();

            var asyncTask = UnitUnderTest.SearchAsync(param);

            while (!asyncTask.IsDone())
            {
                Thread.Sleep(50);
            }

            Assert.IsTrue(asyncTask.IsDone());
        }
示例#5
0
        public void ShouldSearchWithMetadataKeyFilter()
        {
            var param = SearchParameter.CreateForAddress(AccountAddress1)
                        .WithMetadataKeyFilter("bytearraykey")
                        .Build();

            var result = UnitUnderTest.Search(param);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreEqual(result.Results.Count, 10);
            Assert.IsTrue(result.Results.TrueForAll(r => r.MessagePayload.Data.Metadata.ContainsKey("bytearraykey")));
        }
示例#6
0
        public void ShouldSearchAsynchronouslyWithFailureCallback()
        {
            var param = SearchParameter.CreateForAddress("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
                        .Build();
            var taskCompletionSource = new TaskCompletionSource <Exception>();
            var asyncCallbacks       = AsyncCallbacks <SearchResult> .Create <SearchResult>(
                null, ex => taskCompletionSource.SetResult(ex));

            UnitUnderTest.SearchAsync(param, asyncCallbacks);
            taskCompletionSource.Task.Wait(5000);

            var exception = taskCompletionSource.Task.Result;

            Assert.IsInstanceOfType(exception, exception.GetType());
        }
        public void ShouldSearchWithFromTransactionId()
        {
            var param = SearchParameter.CreateForAddress("SDB5DP6VGVNPSQJYEC2X3QIWKAFJ3DCMNQCIF6OA")
                        .WithFromTransactionId("5BDEDB565D6F4B0001155AFF")
                        .Build();

            var result = UnitUnderTest.Search(param);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreEqual(result.Results.Count, 10);
            Assert.AreEqual(result.Results[0].TransactionHash,
                            "471C6C6A3EAC3F18849C1CA2C06D532AA2A83D7E89D99858F52DEE6DCD0D3762");
            Assert.IsNotNull(result.ToTransactionId);
            Assert.AreEqual(result.FromTransactionId, "5BDEDB565D6F4B0001155AFF");
        }
示例#8
0
        public void ShouldSearchAsynchronouslyWithSuccessCallback()
        {
            var param = SearchParameter.CreateForAddress(AccountAddress1).Build();

            var taskCompletionSource = new TaskCompletionSource <SearchResult>();
            var asyncCallbacks       = AsyncCallbacks <SearchResult> .Create <SearchResult>(
                searchResult => taskCompletionSource.SetResult(searchResult), null);

            UnitUnderTest.SearchAsync(param, asyncCallbacks);
            taskCompletionSource.Task.Wait(5000);

            var result = taskCompletionSource.Task.Result;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreEqual(result.Results.Count, 10);
        }
示例#9
0
        public void ShouldSearchWithAllFilter()
        {
            var param = SearchParameter.CreateForAddress(AccountAddress1)
                        .WithNameFilter("byte array")
                        .WithDescriptionFilter("byte array description")
                        .WithMetadataKeyFilter("bytearraykey")
                        .WithMetadataValueFilter("bytearrayval")
                        .Build();

            var result = UnitUnderTest.Search(param);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreEqual(result.Results.Count, 10);
            Assert.IsTrue(result.Results.TrueForAll(r => r.MessagePayload.Data.Name.Contains("byte array")));
            Assert.IsTrue(result.Results.TrueForAll(r =>
                                                    r.MessagePayload.Data.Description.Contains("byte array description")));
            Assert.IsTrue(result.Results.TrueForAll(r =>
                                                    "bytearrayval".Equals(r.MessagePayload.Data.Metadata["bytearraykey"])));
        }
示例#10
0
 public void FailSearchWithLessThan1ResultSize()
 {
     SearchParameter.CreateForAddress(AccountAddress1)
     .WithResultSize(0)
     .Build();
 }
示例#11
0
 public void FailSearchWithMoreThan20ResultSize()
 {
     SearchParameter.CreateForAddress(AccountAddress1)
     .WithResultSize(21)
     .Build();
 }