public void WorksLikeTheOriginal()
        {
            var original = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9}.AsQueryable();
            var wrapped = ExtendedQueryable.Create(original);

            Assert.IsTrue(original.SequenceEqual(wrapped));
            Assert.IsTrue(original.SequenceEqual(wrapped.Select(n => n)));
            Assert.IsTrue(original.Where(n => n > 5).SequenceEqual(wrapped.Where(n => n > 5)));
            Assert.AreEqual(original.ElementType,wrapped.ElementType);
            Assert.AreEqual(original.Expression, wrapped.Expression);
        }
        public void TestClientCertificates()
        {
            var settings = new SslSettings();
            Assert.AreEqual(null, settings.ClientCertificates);

            var clientCertificates = new[] { new X509Certificate2("testcert.pfx", "password"), new X509Certificate2("testcert.pfx", "password") };
            settings.ClientCertificates = clientCertificates;
            Assert.IsTrue(clientCertificates.SequenceEqual(settings.ClientCertificates));
            Assert.AreNotSame(clientCertificates[0], settings.ClientCertificates.ElementAt(0));
            Assert.AreNotSame(clientCertificates[1], settings.ClientCertificates.ElementAt(1));

            settings.Freeze();
            Assert.IsTrue(clientCertificates.SequenceEqual(settings.ClientCertificates));
            Assert.Throws<InvalidOperationException>(() => { settings.ClientCertificates = clientCertificates; });
        }
 public void RuleGeneratorMakesFizz()
 {
     var gen = new RuleGenerator();
     var output = gen.GenerateRuleSequence(3, "fizz");
     var answer = new[]{"", "", "fizz"};
     Assert.That(answer.SequenceEqual(output));
 }
 public void CustomizeAddsSpecializedNumericSpecimenBuildersToFixture()
 {
     // Fixture setup
     var expectedBuilders = new[]
     {
         typeof(ByteSequenceGenerator),
         typeof(DecimalSequenceGenerator),
         typeof(DoubleSequenceGenerator),
         typeof(Int16SequenceGenerator),
         typeof(Int32SequenceGenerator),
         typeof(Int64SequenceGenerator),
         typeof(SByteSequenceGenerator),
         typeof(SingleSequenceGenerator),
         typeof(UInt16SequenceGenerator),
         typeof(UInt32SequenceGenerator),
         typeof(UInt64SequenceGenerator)
     };
     var fixture = new Fixture();
     var sut = new NumericSequencePerTypeCustomization();
     // Exercise system
     sut.Customize(fixture);
     var result = fixture.Customizations
         .OfType<CompositeSpecimenBuilder>()
         .SelectMany(i => i)
         .Select(i => i.GetType());
     // Verify outcome
     Assert.True(expectedBuilders.SequenceEqual(result));
     // Teardown
 }
Example #5
0
        public void SubscribeAllTest()
        {
            string cmd = FeedCommand.SubscribeCommandParameter;
            int marketId = 1;
            string identifier = "id";

            FeedCommand<SubscribeInstrumentArgsBase>[] feedCommands = FeedCommand.SubscribeAll(new InstrumentDescriptor(marketId, identifier));

            var expecteds = new[]
                {
                    string.Format(@"{{""cmd"":""{0}"",""args"":{{""t"":""{1}"",""i"":""{2}"",""m"":{3}}}}}", cmd, "price", identifier, marketId),
                    string.Format(@"{{""cmd"":""{0}"",""args"":{{""t"":""{1}"",""i"":""{2}"",""m"":{3}}}}}", cmd, "depth", identifier, marketId),
                    string.Format(@"{{""cmd"":""{0}"",""args"":{{""t"":""{1}"",""i"":""{2}"",""m"":{3}}}}}", cmd, "trade", identifier, marketId),
                    string.Format(@"{{""cmd"":""{0}"",""args"":{{""t"":""{1}"",""i"":""{2}"",""m"":{3}}}}}", cmd, "index", identifier, marketId),
                    string.Format(@"{{""cmd"":""{0}"",""args"":{{""t"":""{1}"",""i"":""{2}"",""m"":{3}}}}}", cmd, "trading_status", identifier, marketId),
                };

            string[] serializeds = feedCommands.Select(x => x.ToJson()).ToArray();
            for (int index = 0; index < expecteds.Length; index++)
            {
                var expected = expecteds[index];
                string actual = serializeds[index];
                Assert.AreEqual(expected,actual);
            }
            Assert.IsTrue(expecteds.SequenceEqual(serializeds));
            foreach (var feedCommand in feedCommands)
            {
                Console.WriteLine(feedCommand.ToJson());
            }
        }
        public void AllowedDestinations_ValidDestinations_SetsDestinations()
        {
            var destinations = new[] {"https://www.nwebsec.com/", "http://klings.org:81/SomePath"};
            _options.AllowedDestinations(destinations);

            Assert.IsTrue(destinations.SequenceEqual(_options.AllowedUris), String.Join(" ",destinations) + " / " + String.Join(" ", _options.AllowedUris));
        }
 public void SutHasCorrectContents()
 {
     // Fixture setup
     var expectedBuilderTypes = new[]
         {
             typeof(StringGenerator),
             typeof(ConstrainedStringGenerator),
             typeof(StringSeedRelay),
             typeof(NumericSequenceGenerator),
             typeof(CharSequenceGenerator),
             typeof(UriGenerator),
             typeof(UriSchemeGenerator),
             typeof(RangedNumberGenerator),
             typeof(RegularExpressionGenerator),
             typeof(StrictlyMonotonicallyIncreasingDateTimeGenerator),
             typeof(BooleanSwitch),
             typeof(GuidGenerator),
             typeof(TypeGenerator),
             typeof(DelegateGenerator),
             typeof(IntPtrGuard)
         };
     // Exercise system
     var sut = new DefaultPrimitiveBuilders();
     // Verify outcome
     Assert.True(expectedBuilderTypes.SequenceEqual(sut.Select(b => b.GetType())));
     // Teardown
 }
        public void MediaTypes_WithParams_SetsPluginTypes()
        {
            _options.MediaTypes("application/pdf", "application/vnd.ms-excel");
            var expectedSequence = new[] { "application/pdf", "application/vnd.ms-excel" };

            Assert.IsTrue(expectedSequence.SequenceEqual(((ICspPluginTypesDirectiveConfiguration)_options).MediaTypes), "Sequences did not match.");
        }
Example #9
0
 public void ShoudSelectIn()
 {
     var list = new[] {1, 2, 3, 4, 5};
     var inClause = new[] {1, 5};
     var resultList = list.Join(inClause, x => x, y => y, (x, y) => x);
     Assert.IsTrue(inClause.SequenceEqual(resultList));
 }
        public void Can_tokenize_text()
        {
            var text = "The quick brown fox jumped over the lazy dog.";
            var expected = new[] { "the", "quick", "brown", "fox", "jump", "over", "the", "lazi", "dog" };
            var actual = FullTextAnalyzer.Tokenize(text).ToArray();

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
        public void CustomSources_ValidSource_SetCustomSources()
        {
            var directive = new CspDirective();

            directive.CustomSources("source1","source2");

            var expectedResult = new[] {"source1", "source2"};
            Assert.IsTrue(expectedResult.SequenceEqual(directive.CustomSources));
        }
Example #12
0
        /// <summary>
        /// Looks for the BMP 2-byte leading signature at the current position in the stream.
        /// Rewinds the stream to its original position when finished.
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static bool IsBmp(Stream stream)
        {
            var magic = new[] { stream.ReadByte(), stream.ReadByte() };

            if (stream.CanSeek)
                stream.Seek(-2, SeekOrigin.Current);

            return magic.SequenceEqual(new[] { 0x42, 0x4D });
        }
        public void ShouldZipEvenNumberedCollection()
        {
            var data = new[] {1L, 2L, 3L, 4L};
            var results = new[] {3L, 7L};
            Func<long,long,long> map = (a, b) => a + b;

            var zipped = data.Zip(map);
            Assert.True(results.SequenceEqual(zipped));
        }
Example #14
0
        public void AddMultipleNull()
        {
            var values = new [] { "Foo", "Foobar" };
            var lookup = new MutableLookup<string, string>();
            lookup.Add (null, values);
            Assert.AreEqual (1, lookup.Count);
            Assert.IsTrue (values.SequenceEqual (lookup[null]), "S");

            Assert.Throws<ArgumentNullException> (() => lookup.Add ("foo", (IEnumerable<string>)null));
        }
 public void TestCreateNoArgs() {
     var server = MongoServer.Create(); // no args!
     var expectedSeedList = new[] { new MongoServerAddress("localhost") };
     Assert.IsNull(server.Settings.DefaultCredentials);
     Assert.AreEqual(0, server.Instances.Count()); // 0 until connected
     Assert.AreEqual(SafeMode.False, server.Settings.SafeMode);
     Assert.AreEqual(false, server.Settings.SlaveOk);
     Assert.AreEqual(MongoServerState.Disconnected, server.State);
     Assert.IsTrue(expectedSeedList.SequenceEqual(server.Settings.Servers));
 }
        public void ShouldApplyLimitUsingTop()
        {
            var sql = "select a,b,c from d where a = 1 order by c";
            var expected = new[]{ "select top 5 a,b,c from d where a = 1 order by c"};

            var pagedSql = new SqlQueryPager().ApplyLimit(sql, 5);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
Example #17
0
		public void Collection_Set_Union()
		{
			var a = new[] { 1, 2, 3, 4, 5, 6, 7 };
			var b = new[] { 4, 5, 6, 7, 8, 9, 10 };
			var expected = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

			var result = _.Collection.Union(a, b);

			Assert.IsTrue(expected.SequenceEqual(result));
		}
 public void SpecificationsMatchesConstructorSpecifications()
 {
     // Fixture setup
     var expectedSpecifications = new[] { new DelegatingRequestSpecification(), new DelegatingRequestSpecification(), new DelegatingRequestSpecification() };
     var sut = new AndRequestSpecification(expectedSpecifications.Cast<IRequestSpecification>());
     // Exercise system
     IEnumerable<IRequestSpecification> result = sut.Specifications;
     // Verify outcome
     Assert.True(expectedSpecifications.SequenceEqual(result));
     // Teardown
 }
        public void TestNetworkInputPort_Sign()
        {
            var rfs = new Dictionary<int, IReceptiveField>();
              rfs[0] = new SignReceptiveField(0.0, 1.0f);
              rfs[1] = new SignReceptiveField(1.0, 1.0f);
              rfs[2] = new SignReceptiveField(2.0, 1.0f);
              rfs[3] = new SignReceptiveField(3.0, 1.0f);
              rfs[4] = new SignReceptiveField(4.0, 1.0f);

              var arr = new []{0.0, 0.0, 0.0, 0.0, 0.0};
              Assert.AreEqual(arr.Length, rfs.Count);

              var port = new NetworkInputPort(arr, rfs);

              port.Set(3.5);
              Assert.IsTrue(arr.SequenceEqual(new []{0.0, 0.0, 0.0, 30.0, 30.0}));

              port.Set(3.0);
              Assert.IsTrue(arr.SequenceEqual(new []{0.0, 0.0, 0.0, 30.0, 0.0}));
        }
        public void SutYieldsInjectedArray()
        {
            var expected = new[]
            {
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder()
            };
            var sut = new AutoPropertiesTarget(expected);

            Assert.True(expected.SequenceEqual(sut));
        }
        public void CanLoadFromFile()
        {
            string fileName = this.rootLocation + "\\file.txt";
            var lines = new[] {"First line", "Second line", "Third line"};

            this.WriteToFile(fileName, lines);

            FileInternalData internalData = this.extractor.GetFileInternalData(fileName);
            Assert.IsNotNull(internalData);
            Assert.AreEqual(fileName, internalData.FileName);
            Assert.IsTrue(lines.SequenceEqual(internalData.Rows));
        }
Example #22
0
        public void ShouldCopeWithAliasedDefaultSortColumn()
        {
            var sql = "select [a] as [foo],[b],[c] from [d] where [a] = 1";
            var expected = new[]{
                "with __data as (select [a] as [foo],[b],[c], row_number() over(order by [a]) as [_#_] from [d] where [a] = 1)"
                + " select [foo],[b],[c] from __data where [_#_] between 31 and 40"};

            var pagedSql = new SqlQueryPager().ApplyPaging(sql, 30, 10);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
Example #23
0
        public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered()
        {
            var sql = "select a,b,c from d where a = 1";
            var expected = new[]{
                "with __data as (select a,b,c, row_number() over(order by a) as [_#_] from d where a = 1)"
                + " select a,b,c from __data where [_#_] between 11 and 30"};

            var pagedSql = new SqlQueryPager().ApplyPaging(sql, 10, 20);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
Example #24
0
		public void Collection_Set_IntersectionBy()
		{
			var a = new[] { 1, 2, 3, 4, 5, 6, 7 };
			var b = new[] { 4, 5, 6, 7, 8, 9, 10 };
			Func<int, string> transform = i => i.ToString();

			var expected = new[] { "4", "5", "6", "7" };

			var result = _.Collection.IntersectionBy(a, b, transform);

			Assert.IsTrue(expected.SequenceEqual(result));
		}
Example #25
0
        public void SutYieldsInjectedArray()
        {
            var expected = new[]
            {
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder()
            };
            var sut = new BehaviorRoot(expected);

            Assert.True(expected.SequenceEqual(sut));
        }
        public void SutYieldsInjectedArray()
        {
            var expected = new[]
            {
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder()
            };
            var sut = new ResidueCollectorNode(expected);

            Assert.True(expected.SequenceEqual(sut));
        }
Example #27
0
        public void Search_AnySearch_SearchPhrasesAreIncludedInSearchResults()
        {
            // Arrange
            var phrases = new[] { "phrase1", "phrase2", "phrase3" };

            // Act
            var results = _searcher.Search(Enumerable.Empty<ISearchee>(), phrases);

            // Assert
            _mockFactory.VerifyAllExpectationsHaveBeenMet();
            Assert.IsTrue(phrases.SequenceEqual(results.Phrases));
        }
        public void VerifyAssembliesCorrectlyInvokesNextVerify()
        {
            // Fixture setup
            var assemblies = new[] { typeof(IdiomaticAssertion).GetType().Assembly, this.GetType().Assembly, typeof(Fixture).GetType().Assembly }.AsEnumerable();

            var observedAssemblies = new List<Assembly>();
            var sut = new DelegatingIdiomaticAssertion { OnAssemblyVerify = observedAssemblies.Add };
            // Exercise system
            sut.Verify(assemblies);
            // Verify outcome
            Assert.True(assemblies.SequenceEqual(observedAssemblies));
            // Teardown
        }
        public void BestTrailHandlerCallsUpdateTest()
        {
            ColonyBestTrailMessage message = CreateBestTrailMessage();
            var nodes = new[]
                        {
                            Substitute.For <ILineToLineNodeConverter>()
                        };
            m_Converter.Nodes.Returns(nodes);

            m_Model.ColonyBestTrailHandler(message);

            Assert.True(nodes.SequenceEqual(m_Model.Nodes));
        }
Example #30
0
		public void Collection_Set_DifferenceBy()
		{
			var a = new[] { 1, 2, 3, 4, 5, 6, 7 };
			var b = new[] { 4, 5, 6, 7, 8, 9, 10 };

			Func<int, string> transform = i => i.ToString();

			var expected = new[] { "1", "2", "3", "8", "9", "10" };

			var result = _.Collection.DifferenceBy(a, b, transform);

			Assert.IsTrue(expected.SequenceEqual(result));
		}