public void Should_exclude_nhibernate_assemblies()
 {
     CollectionAssert.AreEquivalent(new string[0],
                                    foundAssemblies.Where(a => a.FullName.ToLower().StartsWith("nhibernate")).ToArray());
 }
 private void AssertSplitEquivalent(string name, params string[] words)
 {
     CollectionAssert.AreEquivalent(name.SplitCamelCaseToWords().ToList(), words);
 }
 public ConfigurationTransformTestCaseBuilder BeTransFormedBy(params string[] transformFiles)
 {
     CollectionAssert.AreEquivalent(transformFiles, mostRecentResult);
     return(this);
 }
        public void MultipleStronglyConnectedComponents()
        {
            var edge12 = new Edge <int>(1, 2);
            var edge23 = new Edge <int>(2, 3);
            var edge24 = new Edge <int>(2, 4);
            var edge25 = new Edge <int>(2, 5);
            var edge31 = new Edge <int>(3, 1);
            var edge34 = new Edge <int>(3, 4);
            var edge46 = new Edge <int>(4, 6);
            var edge56 = new Edge <int>(5, 6);
            var edge57 = new Edge <int>(5, 7);
            var edge64 = new Edge <int>(6, 4);
            var edge75 = new Edge <int>(7, 5);
            var edge78 = new Edge <int>(7, 8);
            var edge86 = new Edge <int>(8, 6);
            var edge87 = new Edge <int>(8, 7);

            var graph = new AdjacencyGraph <int, Edge <int> >();

            graph.AddVerticesAndEdgeRange(new[]
            {
                edge12, edge23, edge24, edge25, edge31, edge34, edge46,
                edge56, edge57, edge64, edge75, edge78, edge86, edge87
            });
            graph.AddVertex(10);

            IMutableBidirectionalGraph <AdjacencyGraph <int, Edge <int> >, CondensedEdge <int, Edge <int>, AdjacencyGraph <int, Edge <int> > > > condensedGraph =
                graph.CondensateStronglyConnected <int, Edge <int>, AdjacencyGraph <int, Edge <int> > >();

            Assert.IsNotNull(condensedGraph);
            Assert.AreEqual(4, condensedGraph.VertexCount);
            Assert.AreEqual(3, condensedGraph.EdgeCount);

            // Condensed edge
            CollectionAssert.AreEquivalent(
                new[] { edge56, edge86 },
                condensedGraph.Edges.ElementAt(0).Edges);
            CollectionAssert.AreEquivalent(
                new[] { edge24, edge34 },
                condensedGraph.Edges.ElementAt(1).Edges);
            CollectionAssert.AreEquivalent(
                new[] { edge25 },
                condensedGraph.Edges.ElementAt(2).Edges);

            // Components
            CollectionAssert.AreEquivalent(
                new[] { 4, 6 },
                condensedGraph.Vertices.ElementAt(0).Vertices);
            CollectionAssert.AreEquivalent(
                new[] { edge46, edge64 },
                condensedGraph.Vertices.ElementAt(0).Edges);

            CollectionAssert.AreEquivalent(
                new[] { 5, 7, 8 },
                condensedGraph.Vertices.ElementAt(1).Vertices);
            CollectionAssert.AreEquivalent(
                new[] { edge57, edge75, edge78, edge87 },
                condensedGraph.Vertices.ElementAt(1).Edges);

            CollectionAssert.AreEquivalent(
                new[] { 1, 2, 3 },
                condensedGraph.Vertices.ElementAt(2).Vertices);
            CollectionAssert.AreEquivalent(
                new[] { edge12, edge23, edge31 },
                condensedGraph.Vertices.ElementAt(2).Edges);

            CollectionAssert.AreEquivalent(
                new[] { 10 },
                condensedGraph.Vertices.ElementAt(3).Vertices);
            CollectionAssert.IsEmpty(condensedGraph.Vertices.ElementAt(3).Edges);
        }
Beispiel #5
0
 public static void EnsureAllTypesAreMapped() => CollectionAssert.AreEquivalent(Enum.GetValues(typeof(ClickHouseTypeCode)), TypeConverter.RegisteredTypes.Distinct());
 public static void MatchesUnsorted <T>(this IEnumerable <T> actual, IEnumerable <T> expected)
 {
     CollectionAssert.AreEquivalent(expected.ToArray(), actual.ToArray(), $"{Environment.NewLine}expected:{expected.Join()}{Environment.NewLine}actual  :{actual.Join()}{Environment.NewLine}");
 }
 public void TestListAll()
 {
     _mockStore1.Setup(x => x.ListAll()).Returns(new[] { _digest1 });
     _mockStore2.Setup(x => x.ListAll()).Returns(new[] { _digest2 });
     CollectionAssert.AreEquivalent(new[] { _digest1, _digest2 }, _testStore.ListAll(), "Should combine results from all stores");
 }
        private async Task ProducerConsumerMultithreadedTest(
            int producerTotalCount,
            int producerChunkCount,
            int consumerTotalCount,
            int consumerChunkCount)
        {
            var producerBuffer = new byte[producerTotalCount];
            var consumerBuffer = new byte[consumerTotalCount];

            var random = new Random();

            random.NextBytes(producerBuffer);

            int producerPosition = 0;
            int consumerPosition = 0;

            using (var ct = new CancellationTokenSource())
            {
                using (var s = new PayloadStream(null))
                {
                    Func <Task> reader = async() =>
                    {
                        while (consumerPosition < consumerBuffer.Length)
                        {
                            int readCount = Math.Min(consumerChunkCount, consumerBuffer.Length - consumerPosition);

                            var bytesRead = await s.ReadAsync(consumerBuffer, consumerPosition, readCount, ct.Token);

                            if (bytesRead == 0)
                            {
                                break;
                            }

                            consumerPosition += bytesRead;
                        }
                    };

                    Func <Task> writer = async() =>
                    {
                        while (producerPosition < producerBuffer.Length)
                        {
                            int writeCount = Math.Min(producerChunkCount, producerBuffer.Length - producerPosition);

                            await s.WriteAsync(producerBuffer, producerPosition, writeCount, ct.Token);

                            producerPosition += writeCount;

                            await Task.Yield();
                        }
                    };

                    var readTask  = reader();
                    var writetask = writer();
                    await Task.WhenAll(readTask, writetask);
                }
            }

            Assert.AreEqual(producerTotalCount, producerPosition);
            var consumableCount = Math.Min(producerTotalCount, consumerTotalCount);

            Assert.AreEqual(consumableCount, consumerPosition);
            CollectionAssert.AreEquivalent(producerBuffer.Take(consumableCount).ToArray(), consumerBuffer.Take(consumableCount).ToArray());
        }
        public void GetMemberNames_NewExpression()
        {
            var actual = ExpressionHelper.GetMemberNames(((Expression <Func <dynamic> >)(() => new { Col1 = "1", Col4 = "4" })).Body).ToArray();

            CollectionAssert.AreEquivalent(new[] { "Col1", "Col4" }, actual);
        }
        public void WithSpaceFixedColumnWidthLineSplit()
        {
            ILineSplitter splitter = new FixedColumnWidthLineSplitter(-2, -5, -3, -6);

            CollectionAssert.AreEquivalent(new[] { "2 ", "5    ", "3  ", "6     " }, splitter.Split("2 5    3  6     ").ToArray());
        }
Beispiel #11
0
        public void TokenAwarePolicyReturnsLocalReplicasFirst()
        {
            var hostList = new List <Host>
            {
                //5 local nodes and 4 remote
                TestHelper.CreateHost("0.0.0.1", "dc1"),
                TestHelper.CreateHost("0.0.0.2", "dc1"),
                TestHelper.CreateHost("0.0.0.3", "dc2"),
                TestHelper.CreateHost("0.0.0.4", "dc2"),
                TestHelper.CreateHost("0.0.0.5", "dc1"),
                TestHelper.CreateHost("0.0.0.6", "dc1"),
                TestHelper.CreateHost("0.0.0.7", "dc2"),
                TestHelper.CreateHost("0.0.0.8", "dc2"),
                TestHelper.CreateHost("0.0.0.9", "dc1")
            };
            var n           = 2;
            var clusterMock = new Mock <ICluster>();

            clusterMock
            .Setup(c => c.AllHosts())
            .Returns(hostList)
            .Verifiable();
            clusterMock
            .Setup(c => c.GetReplicas(It.IsAny <string>(), It.IsAny <byte[]>()))
            .Returns <string, byte[]>((keyspace, key) =>
            {
                var i = key[0];
                return(hostList.Where(h =>
                {
                    //The host at with address == k || address == k + n
                    var address = TestHelper.GetLastAddressByte(h);
                    return address == i || address == i + n;
                }).ToList());
            })
            .Verifiable();

            var policy = new TokenAwarePolicy(new DCAwareRoundRobinPolicy("dc1", 2));

            policy.Initialize(clusterMock.Object);

            //key for host :::1 and :::3
            var k = new RoutingKey {
                RawRoutingKey = new byte[] { 1 }
            };
            var hosts = policy.NewQueryPlan(null, new SimpleStatement().SetRoutingKey(k)).ToList();

            //5 local hosts + 2 remote hosts
            Assert.AreEqual(7, hosts.Count);
            //local replica first
            Assert.AreEqual(1, TestHelper.GetLastAddressByte(hosts[0]));
            clusterMock.Verify();

            //key for host :::2 and :::5
            k = new RoutingKey {
                RawRoutingKey = new byte[] { 2 }
            };
            n     = 3;
            hosts = policy.NewQueryPlan(null, new SimpleStatement().SetRoutingKey(k)).ToList();
            Assert.AreEqual(7, hosts.Count);
            //local replicas first
            CollectionAssert.AreEquivalent(new[] { 2, 5 }, hosts.Take(2).Select(TestHelper.GetLastAddressByte));
            //next should be local nodes
            Assert.AreEqual("dc1", hosts[2].Datacenter);
            Assert.AreEqual("dc1", hosts[3].Datacenter);
            Assert.AreEqual("dc1", hosts[4].Datacenter);
            clusterMock.Verify();
        }
        public void FixedColumnWidthLineSplit()
        {
            ILineSplitter splitter = new FixedColumnWidthLineSplitter(2, 5, 3, 6);

            CollectionAssert.AreEquivalent(new[] { "22", "55555", "333", "666666" }, splitter.Split("2255555333666666").ToArray());
        }
Beispiel #13
0
 public void VerifyRevisionCount()
 {
     CollectionAssert.AreEquivalent(new[] { 1 }, AuditReader().GetRevisions(typeof(ContainedEntity), cce1_id));
     CollectionAssert.AreEquivalent(new[] { 1 }, AuditReader().GetRevisions(typeof(SetEntity), cse1_id));
 }
Beispiel #14
0
        [Test] public void LoadPlugins()
        {
            //
            // In this test, we're going to check overall LoadPlugins behavior,
            // as well as the specific case of selective loading, where non-editor
            // plugins and non-plugins are filtered out before loading.
            //
            using (MockPluginLoader pluginLoader = new MockPluginLoader())
            {
                // Set up some mock data for available assemblies
                MockAssembly[] mockPlugins = new MockAssembly[]
                {
                    new MockAssembly("MockDir/MockPluginA.editor.dll", typeof(MockEditorPlugin)),
                    new MockAssembly("MockDir/MockPluginB.editor.dll", typeof(MockEditorPlugin)),
                    new MockAssembly("MockDir2/MockPluginC.editor.dll", typeof(MockEditorPlugin))
                };
                MockAssembly[] mockNoise = new MockAssembly[]
                {
                    new MockAssembly("MockDir/MockAuxillaryA.dll"),
                    new MockAssembly("MockDir/MockPluginD.core.dll", typeof(MockEditorPlugin)),
                    new MockAssembly("MockDir/MockPluginE.editor.dll"),
                    new MockAssembly("MockDir2/MockAuxillaryB.dll", typeof(MockEditorPlugin)),
                    MockAssembly.CreateInvalid("MockDir2/MockPluginF.editor.dll"),
                    MockAssembly.CreateInvalid("MockDir2/MockAuxillaryC.dll")
                };
                string[] mockLoadedPaths = new string[] {
                    mockPlugins[0].Location, mockPlugins[1].Location, mockPlugins[2].Location,
                    mockNoise[2].Location, mockNoise[4].Location
                };

                pluginLoader.AddBaseDir("MockDir");
                pluginLoader.AddBaseDir("MockDir2");
                for (int i = 0; i < mockPlugins.Length; i++)
                {
                    pluginLoader.AddPlugin(mockPlugins[i]);
                }
                for (int i = 0; i < mockNoise.Length; i++)
                {
                    pluginLoader.AddPlugin(mockNoise[i]);
                }
                pluginLoader.AddIncompatibleDll("MockDir2/MockAuxillaryD.dll");

                // Set up a plugin manager using the mock loader
                EditorPluginManager pluginManager = new EditorPluginManager();
                pluginManager.Init(pluginLoader);

                // Load all plugins
                pluginManager.LoadPlugins();
                EditorPlugin[] loadedPlugins = pluginManager.LoadedPlugins.ToArray();

                // Assert that we loaded all expected plugins, but nothing more
                Assert.AreEqual(3, loadedPlugins.Length);
                CollectionAssert.AreEquivalent(mockPlugins, loadedPlugins.Select(plugin => plugin.PluginAssembly));

                // Assert that we properly assigned all plugin properties
                Assert.IsTrue(loadedPlugins.All(plugin => plugin.AssemblyName == plugin.PluginAssembly.GetShortAssemblyName()));

                // Assert that we loaded core plugin and auxilliary libraries, but not editor plugins
                CollectionAssert.AreEquivalent(
                    mockLoadedPaths,
                    pluginLoader.LoadedAssemblies);

                // Assert that we can access all assemblies and types from plugins
                foreach (MockAssembly mockAssembly in mockPlugins)
                {
                    CollectionAssert.Contains(pluginManager.GetAssemblies(), mockAssembly);
                }
                CollectionAssert.Contains(pluginManager.GetTypes(typeof(object)), typeof(MockEditorPlugin));
                Assert.AreEqual(3, pluginManager.GetTypes(typeof(MockEditorPlugin)).Count());

                pluginManager.Terminate();
            }
        }
        public void GetAzureStoreAddOnAvailableAddOnsSuccessfull()
        {
            // Setup
            List <WindowsAzureOffer> actualWindowsAzureOffers = new List <WindowsAzureOffer>();

            mockCommandRuntime.Setup(f => f.WriteObject(It.IsAny <object>(), true))
            .Callback <object, bool>((o, b) => actualWindowsAzureOffers = (List <WindowsAzureOffer>)o);
            List <Plan> plans = new List <Plan>();

            plans.Add(new Plan()
            {
                PlanIdentifier = "Bronze"
            });
            plans.Add(new Plan()
            {
                PlanIdentifier = "Silver"
            });
            plans.Add(new Plan()
            {
                PlanIdentifier = "Gold"
            });
            plans.Add(new Plan()
            {
                PlanIdentifier = "Silver"
            });
            plans.Add(new Plan()
            {
                PlanIdentifier = "Gold"
            });

            List <Offer> expectedOffers = new List <Offer>()
            {
                new Offer()
                {
                    ProviderIdentifier = "Microsoft", OfferIdentifier = "Bing Translate",
                    ProviderId         = new Guid("f8ede0df-591f-4722-b646-e5eb86f0ae52")
                },
                new Offer()
                {
                    ProviderIdentifier = "NotExistingCompany", OfferIdentifier = "Not Existing Name",
                    ProviderId         = new Guid("723138c2-0676-4bf6-80d4-0af31479dac4")
                },
                new Offer()
                {
                    ProviderIdentifier = "OneSDKCompany", OfferIdentifier = "Windows Azure PowerShell",
                    ProviderId         = new Guid("1441f7f7-33a1-4dcf-aeea-8ed8bc1b2e3d")
                }
            };
            List <WindowsAzureOffer> expectedWindowsAzureOffers = new List <WindowsAzureOffer>();

            expectedOffers.ForEach(o => expectedWindowsAzureOffers.Add(new WindowsAzureOffer(
                                                                           o,
                                                                           plans,
                                                                           new List <string>()
            {
                "West US", "East US"
            })));

            mockMarketplaceClient.Setup(f => f.GetAvailableWindowsAzureOffers(It.IsAny <string>()))
            .Returns(expectedWindowsAzureOffers);
            mockMarketplaceClient.Setup(f => f.IsKnownProvider(It.IsAny <Guid>())).Returns(true);

            mockStoreClient.Setup(f => f.GetLocations())
            .Returns(new List <Location>()
            {
                new Location()
                {
                    Name = "West US"
                },
                new Location()
                {
                    Name = "East US"
                }
            });
            cmdlet.ListAvailable = true;

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            mockMarketplaceClient.Verify(f => f.GetAvailableWindowsAzureOffers(null), Times.Once());
            CollectionAssert.AreEquivalent(expectedWindowsAzureOffers, actualWindowsAzureOffers);
        }
 public void Ctor_ShouldInitLayoutsCorrectly_WhenRequired()
 {
     CollectionAssert.AreEquivalent(new[] { LayoutDescriptor.Simple, LayoutDescriptor.Pattern }, mSut.Layouts);
 }
Beispiel #17
0
        public void TestSimpleBlockchainSplit()
        {
            using (var daemon1 = new TestDaemon())
            {
                // add some simple blocks
                var block1 = daemon1.MineAndAddEmptyBlock(daemon1.GenesisBlock);
                var block2 = daemon1.MineAndAddEmptyBlock(block1);

                // introduce a tie split
                var block3a = daemon1.MineAndAddEmptyBlock(block2);
                var block3b = daemon1.MineAndAddEmptyBlock(block2);

                // check that 3a is current as it was first
                daemon1.WaitForDaemon();
                AssertMethods.AssertDaemonAtBlock(3, block3a.Hash, daemon1.BlockchainDaemon);

                // continue split
                var block4a = daemon1.MineAndAddEmptyBlock(block3a);
                var block4b = daemon1.MineAndAddEmptyBlock(block3b);

                // check that 4a is current as it was first
                daemon1.WaitForDaemon();
                AssertMethods.AssertDaemonAtBlock(4, block4a.Hash, daemon1.BlockchainDaemon);

                // resolve tie split, with other chain winning
                var block5b = daemon1.MineAndAddEmptyBlock(block4b);

                // check that blockchain reorged to the winning chain
                daemon1.WaitForDaemon();
                AssertMethods.AssertDaemonAtBlock(5, block5b.Hash, daemon1.BlockchainDaemon);

                // continue on winning fork
                var block6b = daemon1.MineAndAddEmptyBlock(block5b);

                // check that blockchain continued on the winning chain
                daemon1.WaitForDaemon();
                AssertMethods.AssertDaemonAtBlock(6, block6b.Hash, daemon1.BlockchainDaemon);

                // create a second blockchain, reusing the genesis from the first
                using (var daemon2 = new TestDaemon(daemon1.GenesisBlock))
                {
                    // add only the winning blocks to the second blockchain
                    daemon2.AddBlock(block1);
                    daemon2.AddBlock(block2);
                    daemon2.AddBlock(block3b);
                    daemon2.AddBlock(block4b);
                    daemon2.AddBlock(block5b);
                    daemon2.AddBlock(block6b);

                    // check second blockchain
                    daemon2.WaitForDaemon();
                    AssertMethods.AssertDaemonAtBlock(6, block6b.Hash, daemon2.BlockchainDaemon);

                    // verify that re-organized blockchain matches winning-only blockchain
                    using (var expectedChainSate = daemon2.BlockchainDaemon.GetChainState())
                        using (var actualChainSate = daemon1.BlockchainDaemon.GetChainState())
                        {
                            var expectedUtxo = expectedChainSate.Utxo;
                            var expectedUnspentTransactions = ImmutableDictionary.CreateRange <UInt256, UnspentTx>(expectedUtxo.GetUnspentTransactions());
                            var expectedUnspentOutputs      = ImmutableDictionary.CreateRange <TxOutputKey, TxOutput>(expectedUtxo.GetUnspentOutputs());

                            var actualUtxo = actualChainSate.Utxo;
                            var actualUnspentTransactions = ImmutableDictionary.CreateRange <UInt256, UnspentTx>(actualUtxo.GetUnspentTransactions());
                            var actualUnspentOutputs      = ImmutableDictionary.CreateRange <TxOutputKey, TxOutput>(actualUtxo.GetUnspentOutputs());

                            CollectionAssert.AreEquivalent(expectedUnspentTransactions, actualUnspentTransactions);
                            CollectionAssert.AreEquivalent(expectedUnspentOutputs, actualUnspentOutputs);
                        }
                }
            }
        }
        public void Ctor_ShouldInitLayoutsCorrectly_WhenNotRequired()
        {
            mSut = new Layout(new ReadOnlyCollection <IProperty>(new List <IProperty>()), mHistoryManager, false);

            CollectionAssert.AreEquivalent(new[] { LayoutDescriptor.None, LayoutDescriptor.Simple, LayoutDescriptor.Pattern }, mSut.Layouts);
        }
        public void TestRuleValuesReturnsProperTags()
        {
            var item = new ContainsComparer();

            CollectionAssert.AreEquivalent(new[] { "contains" }, item.RuleKeys.ToList());
        }
Beispiel #20
0
 public void VerifyRevisionCount()
 {
     CollectionAssert.AreEquivalent(new[] { 1, 2 }, AuditReader().GetRevisions(typeof(PrimitiveCustomTypeEntity), pctec_id));
 }
 public void TestListAllTemp()
 {
     _mockStore1.Setup(x => x.ListAllTemp()).Returns(new[] { "abc" });
     _mockStore2.Setup(x => x.ListAllTemp()).Returns(new[] { "def" });
     CollectionAssert.AreEquivalent(new[] { "abc", "def" }, _testStore.ListAllTemp(), "Should combine results from all stores");
 }
Beispiel #22
0
 public void getLessonByGroup()
 {
     CollectionAssert.AreEquivalent(ct.GetLessonByGroup(ld.group), ldl);
 }
Beispiel #23
0
        public void FeedTest()
        {
            var feed1 = new Feed();

            feed1.FeedType = FeedType.News;
            feed1.Caption  = "aaa";
            feed1.Text     = "bbb";
            var feed1Id = feedStorage.SaveFeed(feed1, TODO, TODO).Id;

            feedStorage.SaveFeed(feed1, TODO, TODO);

            var feed2 = new Feed();

            feed2.FeedType = FeedType.Order;
            feed2.Caption  = "ccca";
            feed2.Text     = "ddd";
            var feed2Id = feedStorage.SaveFeed(feed2, TODO, TODO).Id;

            var feeds = feedStorage.GetFeeds(FeedType.News, Guid.Empty, 0, 0);

            CollectionAssert.AreEquivalent(new[] { feed1 }, feeds);
            feeds = feedStorage.GetFeeds(FeedType.Order, Guid.Empty, 0, 0);
            CollectionAssert.AreEquivalent(new[] { feed2 }, feeds);
            feeds = feedStorage.GetFeeds(FeedType.Advert, Guid.Empty, 0, 0);
            CollectionAssert.IsEmpty(feeds);

            feeds = feedStorage.GetFeeds(FeedType.All, Guid.NewGuid(), 0, 0);
            CollectionAssert.IsEmpty(feeds);

            feeds = feedStorage.SearchFeeds("c", FeedType.All, Guid.Empty, 0, 0);
            CollectionAssert.AreEquivalent(new[] { feed2 }, feeds);
            feeds = feedStorage.SearchFeeds("a");
            CollectionAssert.AreEquivalent(new[] { feed1, feed2 }, feeds);

            var feedTypes = feedStorage.GetUsedFeedTypes();

            CollectionAssert.AreEquivalent(new[] { FeedType.News, FeedType.Order }, feedTypes);

            feed2 = feedStorage.GetFeed(feed2Id);
            Assert.IsAssignableFrom(typeof(FeedNews), feed2);
            Assert.AreEqual(FeedType.Order, feed2.FeedType);
            Assert.AreEqual("ccca", feed2.Caption);
            Assert.AreEqual("ddd", feed2.Text);

            var c1 = new FeedComment(feed1Id)
            {
                Comment = "c1", Inactive = true
            };
            var c2 = new FeedComment(feed1Id)
            {
                Comment = "c2"
            };
            var c3 = new FeedComment(feed2Id)
            {
                Comment = "c3"
            };
            var c1Id = feedStorage.SaveFeedComment(c1).Id;
            var c2Id = feedStorage.SaveFeedComment(c2).Id;

            feedStorage.SaveFeedComment(c3);
            feedStorage.SaveFeedComment(c3);

            var comments = feedStorage.GetFeedComments(feed2Id);

            CollectionAssert.AreEquivalent(new[] { c3 }, comments);

            comments = feedStorage.GetFeedComments(feed1Id);
            CollectionAssert.AreEquivalent(new[] { c1, c2 }, comments);

            feedStorage.RemoveFeedComment(c2Id);
            comments = feedStorage.GetFeedComments(feed1Id);
            CollectionAssert.AreEquivalent(new[] { c1 }, comments);

            c1 = feedStorage.GetFeedComment(c1Id);
            Assert.AreEqual("c1", c1.Comment);
            Assert.IsTrue(c1.Inactive);

            feedStorage.ReadFeed(feed2Id, SecurityContext.CurrentAccount.ID.ToString());

            feedStorage.RemoveFeed(feed2Id);
            feedStorage.RemoveFeed(feed1Id);
            feed1 = feedStorage.GetFeed(feed1Id);
            Assert.IsNull(feed1);
            comments = feedStorage.GetFeedComments(feed1Id);
            CollectionAssert.IsEmpty(comments);
        }
Beispiel #24
0
 public void getLessonByTeacher()
 {
     CollectionAssert.AreEquivalent(ct.GetLessonByTeacher(ld.teacher), ldl);
 }
 public void VerifyRevisionCounts()
 {
     CollectionAssert.AreEquivalent(new[] { 1, 2 }, AuditReader().GetRevisions(typeof(StrTestEntity), id));
 }
Beispiel #26
0
 public void getLessonByAuditory()
 {
     CollectionAssert.AreEquivalent(ct.GetLessonByAuditory(ld.auditory), ldl);
 }
Beispiel #27
0
 public void VerifyRevisionCount()
 {
     CollectionAssert.AreEquivalent(new[] { 1, 2 }, AuditReader().GetRevisions(typeof(OptimisticLockEntity), id));
 }
Beispiel #28
0
 public void getLessonByDiscipline()
 {
     CollectionAssert.AreEquivalent(ct.GetLessonByDiscipline(ld.discipline), ldl);
 }
        public async Task ItShouldChargeAllNecessaryUsers()
        {
            this.timestampCreator.SetupSequence(v => v.Now()).Returns(Now1).Returns(Now2);
            this.guidCreator.SetupSequence(v => v.CreateSqlSequential()).Returns(TransactionReference1.Value).Returns(TransactionReference2.Value);

            var userId1 = UserId.Random();
            var userId2 = UserId.Random();
            var userId3 = UserId.Random();
            var userId4 = UserId.Random();
            var userId5 = UserId.Random();
            var input   = new List <CalculatedAccountBalanceResult>
            {
                new CalculatedAccountBalanceResult(DateTime.UtcNow, UserId.Random(), LedgerAccountType.FifthweekCredit, TopUpUserAccountsWithCredit.MinimumAccountBalanceBeforeCharge),
                new CalculatedAccountBalanceResult(DateTime.UtcNow, UserId.Random(), LedgerAccountType.Stripe, 0),
                new CalculatedAccountBalanceResult(DateTime.UtcNow, userId1, LedgerAccountType.FifthweekCredit, TopUpUserAccountsWithCredit.MinimumAccountBalanceBeforeCharge - 1),
                new CalculatedAccountBalanceResult(DateTime.UtcNow, userId2, LedgerAccountType.FifthweekCredit, -1m),
            };

            var usersRequiringRetry = new List <UserId> {
                userId3, userId4, userId5
            };

            this.getUsersRequiringPaymentRetry.Setup(v => v.ExecuteAsync()).ReturnsAsync(usersRequiringRetry);

            var usersRequiringCharge = new List <UserId> {
                userId1, userId2, userId3, userId4, userId5
            };

            this.incrementPaymentStatus.Setup(v => v.ExecuteAsync(It.IsAny <IReadOnlyList <UserId> >()))
            .Callback <IReadOnlyList <UserId> >(v => CollectionAssert.AreEquivalent(usersRequiringCharge, v.ToList()))
            .Returns(Task.FromResult(0)).Verifiable();

            this.getUserWeeklySubscriptionsCost.Setup(v => v.ExecuteAsync(userId1)).ReturnsAsync(TopUpUserAccountsWithCredit.MinimumPaymentAmount - 1);
            this.getUserWeeklySubscriptionsCost.Setup(v => v.ExecuteAsync(userId2)).ReturnsAsync(TopUpUserAccountsWithCredit.MinimumPaymentAmount + 1);
            this.getUserWeeklySubscriptionsCost.Setup(v => v.ExecuteAsync(userId3)).ReturnsAsync(0);
            this.getUserWeeklySubscriptionsCost.Setup(v => v.ExecuteAsync(userId4)).ReturnsAsync(TopUpUserAccountsWithCredit.MinimumPaymentAmount * 2);
            this.getUserWeeklySubscriptionsCost.Setup(v => v.ExecuteAsync(userId5)).ReturnsAsync(TopUpUserAccountsWithCredit.MinimumPaymentAmount * 2);

            this.getUserPaymentOrigin.Setup(v => v.ExecuteAsync(userId1))
            .ReturnsAsync(new UserPaymentOriginResult("customer1", PaymentOriginKeyType.Stripe, null, null, null, null, PaymentStatus.Retry1));
            this.getUserPaymentOrigin.Setup(v => v.ExecuteAsync(userId2))
            .ReturnsAsync(new UserPaymentOriginResult("customer2", PaymentOriginKeyType.Stripe, null, null, null, null, PaymentStatus.Retry1));

            // Test PaymentOriginKeyType with no key.
            this.getUserPaymentOrigin.Setup(v => v.ExecuteAsync(userId4))
            .ReturnsAsync(new UserPaymentOriginResult(null, PaymentOriginKeyType.Stripe, null, null, null, null, PaymentStatus.Retry1));

            this.getUserPaymentOrigin.Setup(v => v.ExecuteAsync(userId5))
            .ReturnsAsync(new UserPaymentOriginResult("customer5", PaymentOriginKeyType.Stripe, null, null, null, null, PaymentStatus.None));

            this.applyUserCredit.Setup(v => v.ExecuteAsync(userId1, Now1, TransactionReference1, PositiveInt.Parse(TopUpUserAccountsWithCredit.MinimumPaymentAmount), null, UserType.StandardUser))
            .Returns(Task.FromResult(0))
            .Verifiable();

            this.applyUserCredit.Setup(v => v.ExecuteAsync(userId2, Now2, TransactionReference2, PositiveInt.Parse(TopUpUserAccountsWithCredit.MinimumPaymentAmount + 1), null, UserType.StandardUser))
            .Returns(Task.FromResult(0))
            .Verifiable();

            var result = await this.target.ExecuteAsync(input, new List <PaymentProcessingException>(), CancellationToken.None);

            this.incrementPaymentStatus.Verify();
            this.applyUserCredit.Verify();

            Assert.IsTrue(result);
        }
 public void Should_exclude_system_assemblies()
 {
     CollectionAssert.AreEquivalent(new string[0],
                                    foundAssemblies.Where(a => a.FullName.StartsWith("System")).ToArray());
 }