public static void NURBS1()
        {
            // Draw a simple NURBS
            // Example from this page:http://www.robthebloke.org/opengl_programming.html

            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();

            var points = new[]
                             {
                                 new VA.Drawing.Point(10, 10),
                                 new VA.Drawing.Point(5, 10),
                                 new VA.Drawing.Point(-5, 5),
                                 new VA.Drawing.Point(-10, 5),
                                 new VA.Drawing.Point(-4, 10),
                                 new VA.Drawing.Point(-4, 5),
                                 new VA.Drawing.Point(-8, 1)
                             };

            var origin = new VA.Drawing.Point(4, 4);
            var scale = new VA.Drawing.Size(1.0/4.0, 1.0/4.0);

            var controlpoints = points.Select(x => (x*scale) + origin).ToList();
            var knots = new double[] {0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 4};
            var degree = 3;
            var weights = controlpoints.Select(i => 1.0).ToList();

            var s0 = page.DrawNURBS(controlpoints, knots, weights, degree);
            s0.Text = "Generic NURBS shape";
        }
        public void RuleMethodTest()
        {
            const string expectedName = "Test";
            var expectedVariables = new[] { VariableUnitTest.simpleVariable, VariableUnitTest.listVariable };

            var statements = new RuleStatementChecker[]
                             {
                             	new TextRuleStatementChecker( "text" ),
                             	new ValueRuleStatementChecker( "value", " " ),
                             	new TextRuleStatementChecker( "text" ),
                             };

            var ruleMethodStatement = RuleMethodStartToString( expectedName, expectedVariables, ",", "<", ">" ) +
                                      "\r\n" + statements.Select( t => t.Text ).Aggregate( ( s1, s2 ) => s1 + s2 ) +
                                      "\r\n" + "<%end%>";

            var actualRuleMethod = ParserHelper.ParseRuleMethod( ruleMethodStatement );

            Assert.That( actualRuleMethod.Name, Is.EqualTo( expectedName ) );
            AssertHelper.AssertVariables( expectedVariables, actualRuleMethod.Variables );

            for (var i = 0; i < statements.Length; i++)
            {
                var statement = statements[i];
                statement.CheckAssert( actualRuleMethod.Statements[i] );
            }
        }
		public void GeoShapeMultiLineString_Deserializes()
		{
			var coordinates = new[] 
			{ 
				new[] { new[] { 102.0, 2.0 }, new[] { 103.0, 2.0 }, new[] { 103.0, 3.0 }, new[] { 102.0, 3.0 } },
				new[] { new[] { 100.0, 0.0 }, new[] { 101.0, 0.0 }, new[] { 101.0, 1.0 }, new[] { 100.0, 1.0 } },
				new[] { new[] { 100.2, 0.2 }, new[] { 100.8, 0.2 }, new[] { 100.8, 0.8 }, new[] { 100.2, 0.8 } } 
			};

			var q = this.SerializeThenDeserialize(
				f => f.GeoShape,
				f => f.GeoShapeMultiLineString(gq => gq
					.OnField(p => p.MyGeoShape)
					.Coordinates(coordinates)
					)
				);

			var query = q as IGeoShapeMultiLineStringQuery;
			query.Should().NotBeNull();
			query.Field.Should().Be("myGeoShape");
			query.Shape.Should().NotBeNull();
			query.Shape.Type.Should().Be("multilinestring");
			query.Shape.Coordinates.SelectMany(c => c.SelectMany(cc => cc)).Should()
				.BeEquivalentTo(coordinates.SelectMany(c => c.SelectMany(cc => cc)));
		}
        public void Test14_1Intersection()
        {
            var array1 = new[] { 1, 1, 1, 2, 3, 4, 5, 7, 7, 10 };
            var array2 = new[] { 1, 1, 2, 2, 3, 4, 6, 7, 9, 9, 10, 11, 11, 25 };

            Assert.IsTrue(Enumerable.SequenceEqual(Problem14_1.GetSortedArrayIntersection(array1, array2), Problem14_1.GetSortedArrayIntersection1(array1, array2)));
        }
        public CsdlSemanticsNavigationPropertyTests()
        {
            var constraints = new[] { new CsdlReferentialConstraint("FK", "ID", null, null) };
            this.collectionProperty = new CsdlNavigationProperty("Collection", "Collection(FQ.NS.EntityType)", null, "Reference", false, null, constraints, null, null);
            this.referenceProperty = new CsdlNavigationProperty("Reference", "FQ.NS.EntityType", false, null, false, null, Enumerable.Empty<CsdlReferentialConstraint>(), null, null);

            var navigationWithoutPartner = new CsdlNavigationProperty("WithoutPartner", "FQ.NS.EntityType", false, null, false, null, Enumerable.Empty<CsdlReferentialConstraint>(), null, null);

            var idProperty = new CsdlProperty("ID", new CsdlNamedTypeReference("Edm.Int32", false, null), false, null, null, null);
            var fkProperty = new CsdlProperty("FK", new CsdlNamedTypeReference("Edm.Int32", false, null), false, null, null, null);
            this.csdlEntityType = new CsdlEntityType("EntityType", null, false, false, false, new CsdlKey(new[] { new CsdlPropertyReference("ID", null) }, null), new[] { idProperty, fkProperty }, new[] { collectionProperty, referenceProperty, navigationWithoutPartner }, null, null);

            var csdlSchema = new CsdlSchema("FQ.NS", null, null, new[] { this.csdlEntityType }, Enumerable.Empty<CsdlEnumType>(), Enumerable.Empty<CsdlOperation>(),Enumerable.Empty<CsdlTerm>(),Enumerable.Empty<CsdlEntityContainer>(),Enumerable.Empty<CsdlAnnotations>(), Enumerable.Empty<CsdlTypeDefinition>(), null, null);
            var csdlModel = new CsdlModel();
            csdlModel.AddSchema(csdlSchema);

            var semanticModel = new CsdlSemanticsModel(csdlModel, new EdmDirectValueAnnotationsManager(), Enumerable.Empty<IEdmModel>());
           
            this.semanticEntityType = semanticModel.FindType("FQ.NS.EntityType") as CsdlSemanticsEntityTypeDefinition;
            this.semanticEntityType.Should().NotBeNull();

            this.semanticCollectionNavigation = this.semanticEntityType.FindProperty("Collection") as CsdlSemanticsNavigationProperty;
            this.semanticReferenceNavigation = this.semanticEntityType.FindProperty("Reference") as CsdlSemanticsNavigationProperty;
            this.semanticNavigationWithoutPartner = this.semanticEntityType.FindProperty("WithoutPartner") as CsdlSemanticsNavigationProperty;

            this.semanticCollectionNavigation.Should().NotBeNull();
            this.semanticReferenceNavigation.Should().NotBeNull();
            this.semanticNavigationWithoutPartner.Should().NotBeNull();
        }
Beispiel #6
0
        public void StartsWith_Remote()
        {
            using (var store = NewRemoteDocumentStore())
            {
                var names = new[]
                {
                    "user/aaaaaa/foo a/bar",
                    "user/aaaaaa/foo b/bar",
                    "user/aaaaaa/foo-c/bar",
                    "user/aaaaaa/foo d/bar",
                    "user/aaaaaa/foo e/bar",
                    "user/bazbar/foo1/baz",
                    "user/bazbar/foo2/baz",
                    "user/bazbar/foo3/baz",
                    "user/bazbar/foo4/baz",
                    "user/bazbar/foo5/baz"
                };

                using (var session = store.OpenSession())
                {
                    foreach (var name in names)
                    {
                        session.Store(new object(), name);
                    }
                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    var objects = session.Advanced.LoadStartingWith<object>(keyPrefix: "user/");
                    Assert.Equal(objects.Length, names.Length);
                }
            }
        }
Beispiel #7
0
        public Rectangle2D GetBounds()
        {
            float ymin = 0;
            float xmin = 0;
            float xmax = this.Viewport.Width;
            float ymax = this.Viewport.Height;

            var matrix = Matrix.Invert(this.GetMatrix() * SpriteBatchExtensions.GetUndoMatrix(this.Viewport));

            var corners = new[]
                {
                    new Vector2(xmin, ymin),
                    new Vector2(xmax, ymin),
                    new Vector2(xmin, ymax),
                    new Vector2(xmax, ymax),
                };

            var vectors = corners.Select(x => Vector2.Transform(x, matrix)).ToList();

            xmin = vectors.Min(x => x.X);
            xmax = vectors.Max(x => x.X);
            ymin = vectors.Min(x => x.Y);
            ymax = vectors.Max(x => x.Y);

            return new Rectangle2D(xmin, xmax, ymax, ymin);
        }
Beispiel #8
0
        public object GetData(int lotId, string path)
        {
            Lot lot = this.lotRepository.GetLotIndex(lotId);
            AircraftDataDO aircraftData = lot.Index.GetPart<AircraftDataDO>("aircraftData").Content;
            AircraftCertAirworthinessDO airworthinessData = lot.Index.GetPart<AircraftCertAirworthinessDO>(path).Content;
            string regPath = string.Format("aircraftCertRegistrationsFM/{0}", airworthinessData.Registration.NomValueId);
            AircraftCertRegistrationFMDO registration = lot.Index.GetPart<AircraftCertRegistrationFMDO>(regPath).Content;

            var json = new
            {
                root = new
                {
                    REG_MARK = registration != null ? registration.RegMark : null,
                    PRODUCER_ALT = aircraftData.AircraftProducer != null ? aircraftData.AircraftProducer.NameAlt: null,
                    PRODUCER_DESIGNATION_ALT = aircraftData.ModelAlt,
                    PRODUCER = aircraftData.AircraftProducer != null ? aircraftData.AircraftProducer.Name : null,
                    PRODUCER_DESIGNATION = aircraftData.Model,
                    AIR_CATEGORY = aircraftData.AirCategory != null ? aircraftData.AirCategory.Name : null,
                    REF_NUMBER = airworthinessData.DocumentNumber,
                    MSN = aircraftData.ManSN,
                }
            };

            return json;
        }
        public void TestWithProvidedExample()
        {
            var universe = new[] { 1, 3, 5, 7, 9, 11, 20, 30, 40 };
            var sets = new[]
            {
                new[] { 20 },
                new[] { 1, 5, 20, 30 },
                new[] { 3, 7, 20, 30, 40 },
                new[] { 9, 30 },
                new[] { 11, 20, 30, 40 },
                new[] { 3, 7, 40 }
            };

            var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());

            var expectedResult = new[]
            {
                sets[2],
                sets[1],
                sets[3],
                sets[4]
            };

            CollectionAssert.AreEqual(expectedResult, selectedSets);
        }
        public void CorrectReferenceToNewCssFile()
        {
            var testData = new[]
            {
                "<html>",
                "   <head>",
                "      <style type=\"text/css\">",
                "         body{float:left;}",
                "      </style>",
                "   </head>",
                "   <body>",
                "      <div>some text</div>",
                "   <body>",
                "</html>"
            };

            var result = Run(testData);

            Assert.AreEqual("<html>", result.StripedContent[0]);
            Assert.AreEqual("   <head>", result.StripedContent[1]);
            Assert.AreEqual("<link href=\"~/Content/BlockCss/Search/LoggingResultGrid.css\" rel=\"stylesheet\" />", result.StripedContent[2]);
            Assert.AreEqual("   </head>", result.StripedContent[3]);
            Assert.AreEqual("   <body>", result.StripedContent[4]);
            Assert.AreEqual("      <div>some text</div>", result.StripedContent[5]);
            Assert.AreEqual("   <body>", result.StripedContent[6]);
            Assert.AreEqual("</html>", result.StripedContent[7]);
        }
Beispiel #11
0
 private void SetAlias(string nextIndex, string alias)
 {
     var indicesForAlias = _client.GetIndicesPointingToAlias(Settings.Alias).ToList();
     var newIndices = new[] {nextIndex};
     _client = new ElasticClientWrapper();
     _client.Swap(alias, indicesForAlias, newIndices);
 }
 public void ClassifyComplexCodeSnippet()
 {
     SetText("function foo() { var s = 's'; }");
     var expected = new[]
     {
         Keyword(0, 8),
         WhiteSpace(8, 1),
         Identifier(9, 3),
         Punctuation(12, 2),
         WhiteSpace(14, 1),
         Punctuation(15, 1),
         WhiteSpace(16, 1),
         Keyword(17, 3),
         WhiteSpace(20, 1),
         Identifier(21, 1),
         WhiteSpace(22, 1),
         Operator(23, 1),
         WhiteSpace(24, 1),
         String(25, 3),
         Punctuation(28, 1),
         WhiteSpace(29, 1),
         Punctuation(30, 1)
     };
     AssertClassificationsOf(TextLine(0), expected);
 }
Beispiel #13
0
        private static float EDamage(Obj_AI_Base target)
        {
            if (target.IsMinion || target.IsMonster)
            {
                int stacksMin = GetMinionStacks(target);
                var indexMin = Program.E.Level - 1;

                var EDamageMinion = new float[] { 20, 30, 40, 50, 60 }[indexMin] + (0.6 * ObjectManager.Player.TotalAttackDamage);

                if (stacksMin > 1)
                {
                    EDamageMinion += ((new float[] { 10, 14, 19, 25, 32 }[indexMin] + (new float[] { 0.2f, 0.225f, 0.25f, 0.275f, 0.3f }[indexMin] * ObjectManager.Player.TotalAttackDamage)) * (stacksMin - 1));
                }

                return ObjectManager.Player.CalculateDamageOnUnit(target, DamageType.Physical, (float)EDamageMinion) * 0.9f;
            }
            else
            {
                if (GetStacks(target) == 0) return 0;

                int stacksChamps = GetStacks(target);
                var indexChamp = Program.E.Level - 1;

                var EDamageChamp = new[] { 0, 20, 30, 40, 50, 60 }[indexChamp] + (0.6 * ObjectManager.Player.TotalAttackDamage);

                if (stacksChamps > 1)
                {
                    EDamageChamp += ((new[] { 0, 10, 14, 19, 25, 32 }[indexChamp] + (new[] { 0, 0.2, 0.225, 0.25, 0.275, 0.3 }[indexChamp] * ObjectManager.Player.TotalAttackDamage)) * (stacksChamps - 1));
                }

                return ObjectManager.Player.CalculateDamageOnUnit(target, DamageType.Physical, (float)EDamageChamp);
            }
        }
        public ActionResult LoadGrid()
        {
            var result = this.students.GetAllStudents().ToList();

            var jsonData = new
            {
                total = 1,
                page = 1,
                records = result.Count,
                rows = (
                        from item in result
                        select new
                        {
                            id = item.Id,
                            cell = new string[]
                            {
                                item.FirstName,
                                item.LastName,
                                item.Course.ToString(),
                                item.GroupNumber.ToString(),
                                item.FacultyName,
                                item.Room?.RoomName,
                                item.Room?.Floor.FloorNumber.ToString(),
                                item.Room?.Floor.Building.Name
                             }
                        }).ToArray()
            };

            return this.Json(jsonData, JsonRequestBehavior.AllowGet);
        }
        public void CorrectMultipleBoostTestDiscovererDispatchingNoExternal()
        {
            var sources = new[]
            {
                "ListContentSupport" + BoostTestDiscoverer.ExeExtension,
                "ParseSources1" + BoostTestDiscoverer.ExeExtension,
                "ParseSources2" + BoostTestDiscoverer.ExeExtension,
                "DllProject1" + BoostTestDiscoverer.DllExtension,
                "DllProject2" + BoostTestDiscoverer.DllExtension,
            };

            var results = this.DiscovererFactory.GetDiscoverers(sources, CreateAdapterSettings());

            Assert.That(results.Count(), Is.EqualTo(2));
            Assert.That(results.FirstOrDefault(x => x.Discoverer is ListContentDiscoverer), Is.Not.Null);
            var lcd = results.First(x => x.Discoverer is ListContentDiscoverer);
            Assert.That(lcd.Sources, Is.EqualTo(new[] { "ListContentSupport" + BoostTestDiscoverer.ExeExtension }));

            Assert.That(results.FirstOrDefault(x => x.Discoverer is SourceCodeDiscoverer), Is.Not.Null);
            var scd = results.First(x => x.Discoverer is SourceCodeDiscoverer);
            Assert.That(scd.Sources, Is.EqualTo(new[] { "ParseSources1" + BoostTestDiscoverer.ExeExtension,
                "ParseSources2" + BoostTestDiscoverer.ExeExtension }));

            Assert.That(results.FirstOrDefault(x => x.Sources.Contains("DllProject1" + BoostTestDiscoverer.DllExtension)), Is.Null);
            Assert.That(results.FirstOrDefault(x => x.Sources.Contains("DllProject2" + BoostTestDiscoverer.DllExtension)), Is.Null);
        }
        public void When_laird_is_defeated_then_all_kobolds_in_hall_are_defeated()
        {
            // Arrange
            var context = new TestContext();
            var player = context.Player;
            var laird = context.CreateCard<KoboldHumanoid>("Drakeclan Laird");
            var ambusher = context.CreateCard<KoboldHumanoid>("Drakeclan Ambusher");
            var cutter = context.CreateCard<KoboldHumanoid>("Drakeclan Cutter");
            var shaman = context.CreateCard<KoboldHumanoid>("Drakeclan Shaman");
            var kobolds = new[] {laird, ambusher, cutter, shaman};
            context.SetTopOfDungeonDeck(kobolds);
            context.AdvanceMonsterToFirstRank(laird);
            var hand = Enumerable.Range(0, 6).Select(x => context.CreateCard<Criochan>("Criochan Captain")).ToArray();
            context.SetPlayerHand(hand);
            var startingXp = player.Xp;
            var startingVp = player.Vp;

            // Act
            context.WhenBattling(laird);
            player.DetermineBattleResult();

            // Assert
            kobolds.Each(x => Assert.That(player.Discard.Contains(x), "Discard does not contain {0}".Template(x.Name)));
            context.Game.Dungeon.Ranks.Each(r=> Assert.That(r.Card, Is.Not.Null, "Rank {0} is empty".Template(r.Number)));
            kobolds.Each(x => Assert.That(context.Game.Dungeon.Ranks.All(rank => rank.Card != x)));
            Assert.That(player.Xp, Is.EqualTo(startingXp + laird.Xp));
            Assert.That(player.Vp, Is.EqualTo(startingVp + kobolds.Sum(x => x.Vp)));
        }
Beispiel #17
0
 public void Render(GraphicsBuffer buffer)
 {
     var pattern = new[]
     {
         scheme.Base,
         scheme.Light,
         scheme.Lighter,
         scheme.Light,
         scheme.Base
     };
     foreach (var index in Enumerable.Range(0, pattern.Length))
         buffer.DrawFrame(
             topRow + index,
             leftColumn + index,
             width - 2 * index,
             height - 2 * index,
             pattern[index]);
     buffer.DrawBackground(
         background,
         topRow + pattern.Length,
         leftColumn + pattern.Length,
         width - 2 * pattern.Length,
         height - 2 * pattern.Length,
         paletteIndex);
 }
Beispiel #18
0
        public object GetSensorTable(HttpRequestParams request)
        {
            using (var session = Context.OpenSession())
            {
                var info = new
                    {
                        host = MqttPlugin.Host,
                        port = MqttPlugin.Port,
                        path = MqttPlugin.Path
                    };

                var messages = session
                                .Query<ReceivedData>()
                                .OrderBy(m => m.Path)
                                .Select(m => new
                                {
                                    id = m.Id,
                                    path = m.Path,
                                    message = m.Message,
                                    timestamp = m.Timestamp
                                }).ToList();

                return new { info, messages };
            }
        }
Beispiel #19
0
        public void Execute()
        {
            //
            // Take拡張メソッドは、シーケンスの先頭から指定された件数分を返すメソッド。
            //
            //   ・シーケンスの要素数より多い数を指定した場合、そのシーケンス全てが返る.
            //   ・0以下の値を指定した場合、空のシーケンスが返る.
            //
            var names = new[] {"gsf_zero1", "gsf_zero2", "gsf_zero3", "gsf_zero4", "gsf_zero5"};

            Output.WriteLine("================ Take ======================");
            var top3 = names.Take(3);
            foreach (var item in top3)
            {
                Output.WriteLine(item);
            }

            foreach (var item in names.Take(20))
            {
                Output.WriteLine(item);
            }

            Output.WriteLine("0以下の数値を指定: COUNT={0}", names.Take(-1).Count());

            //
            // TakeWhile拡張メソッドは、指定された条件が満たされる間シーケンスから要素を抽出し
            // 返すメソッド。
            //
            Output.WriteLine("================ TakeWhile ======================");
            var lessThan4 = names.TakeWhile(name => int.Parse(name.Last().ToString()) <= 4);
            foreach (var item in lessThan4)
            {
                Output.WriteLine(item);
            }
        }
 public void Test1Number()
 {
     var sequence = new[] { 5 };
     var expectedSeq = new[] { 5 };
     var actualSeq = LongestIncreasingSubsequence.FindLongestIncreasingSubsequence(sequence);
     CollectionAssert.AreEqual(expectedSeq, actualSeq);
 }
        public void ThenNoRoutesFollowTheRoutesFromTheController(string controllerName)
        {
            var count = 0;
            var indexOfLastRouteForController = 0;
            var routes = RouteTable.Routes.Cast<Route>();

            foreach (var route in routes.ToList())
            {
                var routeControllerName = route.Defaults["controller"].ToString();
                var skipControllerNames = new[]
                {
                    "RoutePrecedenceAmongTheSitesRoutes",
                    "RoutePrecedenceViaRouteProperties"
                };

                if (skipControllerNames.Any(routeControllerName.EndsWith))
                {
                    // Skip the controllers that will come after controllers registered through the config object
                    // due to have actions that specify a SitePrecedence property.
                    continue;
                }

                if (routeControllerName == controllerName)
                    indexOfLastRouteForController = count;

                count++;
            }

            Assert.That(indexOfLastRouteForController, Is.EqualTo(count - 1));
        }
 public void Test23Numbers()
 {
     var sequence = new[] { 3, 14, 5, 12, 15, 7, 8, 9, 11, 10, 1, 12, 13, 14, 20, 15, 30, 16, 17, 40, 18, 19, 20 };
     var expectedSeq = new[] { 3, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
     var actualSeq = LongestIncreasingSubsequence.FindLongestIncreasingSubsequence(sequence);
     CollectionAssert.AreEqual(expectedSeq, actualSeq);
 }
        public void ComplicatedSentencesShouldBeSplittedCorrectly()
        {
            var service = GetService();

            var input = "\"I'd look at McDonald's,\" he said.";
            var actual = service.SplitIntoWords(input);
            var expected = new[] { "I'd", "look", "at", "McDonald's", "he", "said" };
            CollectionAssert.AreEqual(expected, actual.ToList());

            input = "\"They sell over 3,000,000 burgers a day-- at $1.50 each.\"";
            actual = service.SplitIntoWords(input);
            expected = new[] { "They", "sell", "over", "3,000,000", "burgers", "a", "day", "at", "$1.50", "each" };
            CollectionAssert.AreEqual(expected, actual.ToList());

            input = "High-fat foods were the rage. For e.g., margins in fries";
            actual = service.SplitIntoWords(input);
            expected = new[] { "High-fat", "foods", "were", "the", "rage", "For", "e.g", "margins", "in", "fries" };
            CollectionAssert.AreEqual(expected, actual.ToList());

            input = "were over 50%... and (except for R&M & Dyana [sic]) everyone";
            actual = service.SplitIntoWords(input);
            expected = new[] { "were", "over", "50%", "and", "except", "for", "R&M", "Dyana", "sic", "everyone" };
            CollectionAssert.AreEqual(expected, actual.ToList());

            input = "was at ~30% net margin; growing at 25% too!";
            actual = service.SplitIntoWords(input);
            expected = new[] { "was", "at", "~30%", "net", "margin", "growing", "at", "25%", "too" };
            CollectionAssert.AreEqual(expected, actual.ToList());

            input = "url: http://somurl.com";
            actual = service.SplitIntoWords(input);
            expected = new[] { "url", "http://somurl.com" };
            CollectionAssert.AreEqual(expected, actual.ToList());
        }
 public void Test6Numbers()
 {
     var sequence = new[] { 30, 1, 20, 2, 3, -1 };
     var expectedSeq = new[] { 1, 2, 3 };
     var actualSeq = LongestIncreasingSubsequence.FindLongestIncreasingSubsequence(sequence);
     CollectionAssert.AreEqual(expectedSeq, actualSeq);
 }
        public void TestCommitOrder() {
            var list = new[] {"@cba-1.0.1", "@cba-1.1.1", "@cba-1.1", "@cba-1.0", "@cba-1"};

            var orderedList = list.OrderBy(x => x);

            orderedList.Should().Equal(new[] {"@cba-1", "@cba-1.0", "@cba-1.0.1", "@cba-1.1", "@cba-1.1.1"});
        }
        public SemanticVersion NextVersion()
        {
            var versionZero = new SemanticVersion();
            var lastRelease = lastTaggedReleaseFinder.GetVersion().SemVer;
            var fileVersion = nextVersionTxtFileFinder.GetNextVersion();
            var mergedBranchVersion = mergedBranchesWithVersionFinder.GetVersion();
            var otherBranchVersion = unknownBranchFinder.FindVersion(context);
            if (otherBranchVersion != null && otherBranchVersion.PreReleaseTag != null && otherBranchVersion.PreReleaseTag.Name == "release")
                otherBranchVersion.PreReleaseTag.Name = "beta";

            var maxCalculated = new[]{ fileVersion, otherBranchVersion, mergedBranchVersion }.Max();

            if (lastRelease == versionZero && maxCalculated == versionZero)
            {
                return new SemanticVersion
                {
                    Minor = 1
                };
            }

            if (maxCalculated <= lastRelease)
            {
                return new SemanticVersion
                {
                    Major = lastRelease.Major,
                    Minor = lastRelease.Minor,
                    Patch = lastRelease.Patch + 1
                };
            }

            return maxCalculated;
        }
        public void PathelogicalSmallAmounts() {
            var weights = new[] { 1, 1, 1 };

            var res = new ProRataDistributor().DistributeAllButLast(0.01M, weights, 2);
            CollectionAssert.AreEqual(new[] { 0, 0, 0.01M }, res);

            res = new ProRataDistributor().DistributeAllButLast(0.02M, weights, 2);
            CollectionAssert.AreEqual(new[] { 0, 0, 0.02M }, res);

            res = new ProRataDistributor().DistributeAllButLast(0.03M, weights, 2);
            CollectionAssert.AreEqual(new[] { 0.01M, 0.01M, 0.01M }, res);

            res = new ProRataDistributor().DistributeAllButLast(0.04M, weights, 2);
            CollectionAssert.AreEqual(new[] { 0.01M, 0.01M, 0.02M }, res);

            res = new ProRataDistributor().DistributeAllButLast(0.05M, weights, 2);
            CollectionAssert.AreEqual(new[] { 0.01M, 0.01M, 0.03M }, res);

            res = new ProRataDistributor().DistributeAllButLast(0.06M, weights, 2);
            CollectionAssert.AreEqual(new[] { 0.02M, 0.02M, 0.02M }, res);

            weights = new[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
            res = new ProRataDistributor().DistributeAllButLast(0.15M, weights, 2);
            CollectionAssert.AreEqual(new[] { 0.01M, 0.01M, 0.01M, 0.01M, 0.01M, 0.01M, 0.01M, 0.01M, 0.01M, 0.06M }, res);
        }
        public void CompileMultipleDescriptors()
        {
            var descriptors = new[]
                                  {
                                      new SparkViewDescriptor().AddTemplate("Home\\Index.spark"),
                                      new SparkViewDescriptor().AddTemplate("Home\\List.spark")
                                  };

            var assembly = engine.BatchCompilation(descriptors);

            var types = assembly.GetTypes();
            Assert.AreEqual(2, types.Count());

            var entry0 = engine.GetEntry(descriptors[0]);
            var view0 = entry0.CreateInstance();
            var result0 = view0.RenderView();
            Assert.AreEqual("<p>Hello world</p>", result0);

            var entry1 = engine.GetEntry(descriptors[1]);
            var view1 = entry1.CreateInstance();
            var result1 = view1.RenderView();
            Assert.AreEqual("<ol><li>one</li><li>two</li></ol>", result1);

            Assert.AreSame(view0.GetType().Assembly, view1.GetType().Assembly);
        }
        public void TheyShouldBeResolvable()
        {
            var interceptorTypes = new[] {typeof (DummyInterceptor)};

            var builder = new ContainerBuilder();
            var typeProvider = Substitute.For<ITypeProvider>();
            typeProvider.InterceptorTypes.Returns(interceptorTypes);

            builder.RegisterNimbus(typeProvider);

            using (var container = builder.Build())
            using (var dependencyResolver = container.Resolve<IDependencyResolver>())
            using (var scope = dependencyResolver.CreateChildScope())
            {
                var interceptorSetting = new GlobalOutboundInterceptorTypesSetting
                                         {
                                             Value = interceptorTypes
                                         };
                var outboundInterceptorFactory = new OutboundInterceptorFactory(interceptorSetting,
                                                                                new PropertyInjector(Substitute.For<IClock>(),
                                                                                                     Substitute.For<IDispatchContextManager>(),
                                                                                                     Substitute.For<ILargeMessageBodyStore>()));

                var dummyNimbusMessage = new NimbusMessage("nullQueue");
                var interceptors = outboundInterceptorFactory.CreateInterceptors(scope, dummyNimbusMessage);

                interceptors.Count().ShouldBe(1);
            }
        }
        public void Serialize()
        {
            var container = new GraphicStreamContainer();
            var positions = new[] { Vector3.XAxis, Vector3.YAxis, Vector3.ZAxis };
            container.Create(GraphicStreamUsage.Position, positions);
            var texCoords = new[] { Vector2.XAxis, Vector2.YAxis };
            container.Create(GraphicStreamUsage.TextureCoordinate, texCoords);

            var filename = "test.txt";
            Serializer.SerializeBinary(container, filename);

            var deserializedContainer = Serializer.DeserializeBinary<GraphicStreamContainer>(filename);

            deserializedContainer.ShouldNotBeNull();
            deserializedContainer.Count().ShouldEqual(2);

            deserializedContainer.GetByUsage(GraphicStreamUsage.Position)
                .ShouldNotBeNull()
                .TypeShouldBe<GraphicStream<Vector3>>()
                .Data.ShouldEqual(positions);

            deserializedContainer.GetByUsage(GraphicStreamUsage.TextureCoordinate)
                .ShouldNotBeNull()
                .TypeShouldBe<GraphicStream<Vector2>>()
                .Data.ShouldEqual(texCoords);
        }