Exemplo n.º 1
0
 public void GetVendors_getsListOfVendors_ListVendor()
 {
     CollectionAssert.AllItemsAreInstancesOfType(Vendor.getVendors(), typeof(Vendor));
 }
Exemplo n.º 2
0
 public void SortedDeckFilledAllCardSlots()
 {
     _deck.Sort();
     CollectionAssert.AllItemsAreNotNull(_deck.Cards);
     CollectionAssert.AllItemsAreInstancesOfType(_deck.Cards, typeof(Card));
 }
Exemplo n.º 3
0
        public void ItemsOfType()
        {
            var collection = new SimpleObjectCollection("x", "y", "z");

            CollectionAssert.AllItemsAreInstancesOfType(collection, typeof(string));
        }
Exemplo n.º 4
0
        public void TestAssertions()
        {
            #region Condition assertions

            Assert.True(true, "Assert.True and Assert.IsTrue test that the specified condition is true. ");


            Assert.IsTrue(true);

            Assert.False(false, "Assert.False and Assert.IsFalse test that the specified condition is false.");
            Assert.IsFalse(false);

            Assert.Null(null);
            Assert.IsNull(null, "Assert.Null and Assert.IsNull test that the specified object is null.");
            Assert.IsNotNull("10");
            Assert.NotNull("10", "");

            Assert.IsNaN(Double.NaN, "Assert.IsNaN tests that the specified double value is NaN (Not a number).");

            Assert.IsEmpty("");
            Assert.IsEmpty(new List <object>());
            Assert.IsNotEmpty(new List <object> {
                1
            });
            Assert.IsNotEmpty("MyTestString");

            #endregion

            #region Equality

            Assert.AreEqual(true, true, "Assert.AreEqual tests whether the two arguments are equal.");
            Assert.AreNotEqual(true, false);

            #endregion

            #region Identity

            Assert.AreSame(string.Empty, string.Empty,
                           "Assert.AreNotSame tests that the two arguments do not reference the same object.");
            Assert.AreNotSame(new object(), new object());

            //both objects are refering to same object
            object a = new object();
            object b = a;
            Assert.AreSame(a, b);
            #endregion

            #region Comparision

            //Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order.
            //Thus Assert.Greater(x, y) asserts that x is greater than y (x > y).
            Assert.Greater(Decimal.MaxValue, Decimal.MinValue,
                           "Assert.Greater tests whether one object is greater than than another");
            Assert.GreaterOrEqual(Decimal.MinValue, Decimal.MinValue);

            Assert.Less(Decimal.MinValue, Decimal.MaxValue);
            Assert.LessOrEqual(Decimal.MinValue, Decimal.MinValue);

            #endregion

            #region Types

            Assert.IsInstanceOf <decimal>(decimal.MinValue,
                                          "Assert.IsInstanceOf succeeds if the object provided as an actual value is an instance of the expected type.");
            Assert.IsNotInstanceOf <int>(decimal.MinValue);

            Assert.IsNotAssignableFrom(typeof(List <Type>), string.Empty,
                                       "Assert.IsAssignableFrom succeeds if the object provided may be assigned a value of the expected type.");
            Assert.IsAssignableFrom(typeof(List <decimal>), new List <decimal>());

            Assert.IsNotAssignableFrom <List <Type> >(string.Empty);
            Assert.IsAssignableFrom <List <decimal> >(new List <decimal>());

            #endregion


            #region Strings

            //The StringAssert class provides a number of methods that are useful when examining string values
            StringAssert.Contains("london", "london");
            StringAssert.StartsWith("Food", "FoodPanda");
            StringAssert.EndsWith("rangers", "Powerrangers");
            StringAssert.AreEqualIgnoringCase("DOG", "dog");
            StringAssert.IsMatch("[10-29]", "15");
            StringAssert.DoesNotContain("abc", "defghijk");
            StringAssert.DoesNotEndWith("abc", "abcdefgh");
            StringAssert.DoesNotMatch("abc", "def");
            string a1 = "abc";
            string b1 = "abcd";
            //StringAssert.ReferenceEquals(a1, b1); need to debug why it's failing

            Assert.Contains(string.Empty, new List <object> {
                string.Empty
            },
                            "Assert.Contains is used to test whether an object is contained in a collection.");

            #endregion

            #region Collections

            //The CollectionAssert class provides a number of methods that are useful when examining collections and
            //their contents or for comparing two collections. These methods may be used with any object implementing IEnumerable.


            //The AreEqual overloads succeed if the corresponding elements of the two collections are equal.
            //AreEquivalent tests whether the collection contents are equal, but without regard to order.
            //In both cases, elements are compared using NUnit's default equality comparison.

            CollectionAssert.AllItemsAreInstancesOfType(new List <decimal> {
                0m
            }, typeof(decimal));
            CollectionAssert.AllItemsAreNotNull(new List <decimal> {
                0m
            });
            CollectionAssert.AllItemsAreUnique(new List <decimal> {
                0m, 1m
            });
            CollectionAssert.AreEqual(new List <decimal> {
                0m
            }, new List <decimal> {
                0m
            });
            CollectionAssert.AreEquivalent(new List <decimal> {
                0m, 1m
            },
                                           new List <decimal> {
                1m, 0m
            });                              // Same as AreEqual though order does not mater
            CollectionAssert.AreNotEqual(new List <decimal> {
                0m
            }, new List <decimal> {
                1m
            });
            CollectionAssert.AreNotEquivalent(new List <decimal> {
                0m, 1m
            },
                                              new List <decimal> {
                1m, 2m
            });                              // Same as AreNotEqual though order does not matter
            CollectionAssert.Contains(new List <decimal> {
                0m, 1m
            }, 1m);
            CollectionAssert.DoesNotContain(new List <decimal> {
                0m, 1m
            }, 2m);
            CollectionAssert.IsSubsetOf(new List <decimal> {
                1m
            },
                                        new List <decimal> {
                0m, 1m
            });                              // {1} is considered a SubSet of {1,2}
            CollectionAssert.IsNotSubsetOf(new List <decimal> {
                1m, 2m
            }, new List <decimal> {
                0m, 1m
            });
            CollectionAssert.IsEmpty(new List <decimal>());
            CollectionAssert.IsNotEmpty(new List <decimal> {
                1m
            });
            CollectionAssert.IsOrdered(new List <decimal> {
                1m, 2m, 3m
            });
            CollectionAssert.IsOrdered(new List <string> {
                "a", "A", "b"
            }, StringComparer.CurrentCultureIgnoreCase);
            CollectionAssert.IsOrdered(new List <int> {
                3, 2, 1
            },
                                       "The list is ordered"); // Only supports ICompare and not ICompare<T> as of version 2.6

            #endregion

            #region File Assert

            //Various ways to compare a stream or file.
            //The FileAssert class provides methods for comparing or verifying the existence of files
            //Files may be provided as Streams, as FileInfos or as strings giving the path to each file.
            FileAssert.AreEqual(new MemoryStream(), new MemoryStream());
            FileAssert.AreEqual(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt"));
            FileAssert.AreEqual("MyFile.txt", "MyFile.txt");
            FileAssert.AreNotEqual(new FileInfo("MyFile.txt"), new FileInfo("MyFile2.txt"));
            FileAssert.AreNotEqual("MyFile.txt", "MyFile2.txt");
            FileAssert.AreNotEqual(new FileStream("MyFile.txt", FileMode.Open),
                                   new FileStream("MyFile2.txt", FileMode.Open));

            FileAssert.Equals(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt"));
            FileAssert.ReferenceEquals(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt"));

            #endregion

            #region Utilities

            // Used to stop test execution and mark them pass or fail or skip

            if (Convert.ToInt32(DateTime.Now.Second) > 30)
            {
                Console.WriteLine("Exaple on Utilities assertions");
                Assert.Ignore();
            }

            if (Convert.ToInt32(DateTime.Now.Second) < 30)
            {
                Assert.Inconclusive();
            }

            // Defining the failed message
            Assert.IsTrue(true, "A failed message here");

            Assert.Pass();
            Assert.Fail();

            #endregion
        }
Exemplo n.º 5
0
        public void AllItemsAreInstanceOfType()
        {
            List <string> str1 = new List <string>();

            CollectionAssert.AllItemsAreInstancesOfType(str1, typeof(string));
        }
Exemplo n.º 6
0
        public void CreateIds_ReturnsGuids()
        {
            var ids = _structureIdGenerator.Generate(Mock.Of <IStructureSchema>(), 10).Select(id => id.Value);

            CollectionAssert.AllItemsAreInstancesOfType(ids, typeof(Guid));
        }
        public void GetAllLiveTournamentGames()
        {
            var liveGames = accessor.GetAllLiveTournamentGames();

            CollectionAssert.AllItemsAreInstancesOfType(liveGames.ToList(), typeof(JsonLiveMatch));
        }
Exemplo n.º 8
0
        public void GenerateIntsTest()
        {
            // Arrange
            int seed = 1337;

            int rounds = 100;

            IntegerGenerator ig1 = new IntegerGenerator();
            IntegerGenerator ig2 = new IntegerGenerator();
            IntegerGenerator ig3 = new IntegerGenerator();
            IntegerGenerator ig4 = new IntegerGenerator();
            IntegerGenerator ig5 = new IntegerGenerator();

            var range2 = (min : 2, max : 10);

            List <object> gene1Objects = new List <object>(capacity: rounds);
            List <object> gene2Objects = new List <object>(capacity: rounds);
            List <object> gene3Objects = new List <object>(capacity: rounds);
            List <object> gene4Objects = new List <object>(capacity: rounds);
            List <object> gene5Objects = new List <object>(capacity: rounds);

            List <bool> gene1Success = new List <bool>(capacity: rounds);
            List <bool> gene2Success = new List <bool>(capacity: rounds);
            List <bool> gene3Success = new List <bool>(capacity: rounds);
            List <bool> gene4Success = new List <bool>(capacity: rounds);
            List <bool> gene5Success = new List <bool>(capacity: rounds);

            // Act
            var shouldBeValidInitResult1 = ig1.Init(null, seed);
            var shouldBeValidInitResult2 = ig2.Init($"{range2.min}..{range2.max}", seed);
            var shouldBeValidInitResult3 = ig3.Init("-100,-66", seed);
            var shouldBeValidInitResult4 = ig4.Init($"{int.MinValue}..{int.MaxValue}", seed);
            var shouldBeValidInitResult5 = ig5.Init("0,1", seed);

            for (int i = 0; i < rounds; i++)
            {
                var genResult1 = ig1.Generate();
                var genResult2 = ig2.Generate();
                var genResult3 = ig3.Generate();
                var genResult4 = ig4.Generate();
                var genResult5 = ig5.Generate();

                gene1Objects.Add(genResult1.result);
                gene2Objects.Add(genResult2.result);
                gene3Objects.Add(genResult3.result);
                gene4Objects.Add(genResult4.result);
                gene5Objects.Add(genResult5.result);

                gene1Success.Add(genResult1.success);
                gene2Success.Add(genResult2.success);
                gene3Success.Add(genResult3.success);
                gene4Success.Add(genResult4.success);
                gene5Success.Add(genResult5.success);

                ig1.NextStep();
                ig2.NextStep();
                ig3.NextStep();
                ig4.NextStep();
                ig5.NextStep();
            }

            // Assert
            Assert.AreEqual(rounds, gene1Objects.Count);
            Assert.AreEqual(rounds, gene2Objects.Count);
            Assert.AreEqual(rounds, gene3Objects.Count);
            Assert.AreEqual(rounds, gene4Objects.Count);
            Assert.AreEqual(rounds, gene5Objects.Count);

            Assert.AreEqual(rounds, gene1Success.Count);
            Assert.AreEqual(rounds, gene2Success.Count);
            Assert.AreEqual(rounds, gene3Success.Count);
            Assert.AreEqual(rounds, gene4Success.Count);
            Assert.AreEqual(rounds, gene5Success.Count);

            CollectionAssert.AllItemsAreInstancesOfType(gene1Objects, typeof(int), "There should be only ints generated");
            CollectionAssert.AllItemsAreInstancesOfType(gene2Objects, typeof(int), "There should be only ints generated");
            CollectionAssert.AllItemsAreInstancesOfType(gene3Objects, typeof(int), "There should be only ints generated");
            CollectionAssert.AllItemsAreInstancesOfType(gene4Objects, typeof(int), "There should be only ints generated");
            CollectionAssert.AllItemsAreInstancesOfType(gene5Objects, typeof(int), "There should be only ints generated");

            var range1 = ig1.GetRange();

            foreach (object val in gene1Objects)
            {
                Assert.GreaterOrEqual((int)val, (int)range1.minRangeInclusive);
                Assert.Less((int)val, (int)range1.maxRangeExclusive);
            }

            Assert.AreEqual(range2.min, (int)ig2.GetRange().minRangeInclusive, "Range min should have been parsed correctly");
            Assert.AreEqual(range2.max, (int)ig2.GetRange().maxRangeExclusive, "Range max should have been parsed correctly");

            foreach (object val in gene2Objects)
            {
                Assert.GreaterOrEqual((int)val, range2.min);
                Assert.Less((int)val, range2.max);
            }
        }
Exemplo n.º 9
0
        public void Create_Empty_Collection_From_Given_Type()
        {
            var data = new PersonDatabase <IPerson>();

            CollectionAssert.AllItemsAreInstancesOfType(data.ToList(), typeof(IPerson));
        }
Exemplo n.º 10
0
 public void All_dispatched_messages_are_commands()
 {
     CollectionAssert.AllItemsAreInstancesOfType(Saga.CommandsToDispatch, typeof(GoToWorkCommand));
 }
Exemplo n.º 11
0
        public void GenerateLongsTest()
        {
            // Arrange
            int seed = 1337;

            int rounds = 100;

            Type longType = typeof(long);

            IntegerGenerator ig1 = new IntegerGenerator();
            IntegerGenerator ig2 = new IntegerGenerator();
            IntegerGenerator ig3 = new IntegerGenerator();

            long intMin = int.MinValue;
            long intMax = int.MaxValue;
            var  range1 = (min : intMin - 1, max : 10);
            var  range2 = (min : -10, max : intMax + 1);
            var  range3 = (min : long.MinValue, max : long.MaxValue);

            List <object> gene1Objects = new List <object>(capacity: rounds);
            List <object> gene2Objects = new List <object>(capacity: rounds);
            List <object> gene3Objects = new List <object>(capacity: rounds);

            List <bool> gene1Success = new List <bool>(capacity: rounds);
            List <bool> gene2Success = new List <bool>(capacity: rounds);
            List <bool> gene3Success = new List <bool>(capacity: rounds);

            // Act
            var shouldBeValidInitResult1 = ig1.Init($"{range1.min}..{range1.max}", seed);
            var shouldBeValidInitResult2 = ig2.Init($"{range2.min}..{range2.max}", seed);
            var shouldBeValidInitResult3 = ig3.Init($"{range3.min}..{range3.max}", seed);

            for (int i = 0; i < rounds; i++)
            {
                var genResult1 = ig1.Generate(null, longType);
                var genResult2 = ig2.Generate(null, longType);
                var genResult3 = ig3.Generate(null, longType);

                gene1Objects.Add(genResult1.result);
                gene2Objects.Add(genResult2.result);
                gene3Objects.Add(genResult3.result);

                gene1Success.Add(genResult1.success);
                gene2Success.Add(genResult2.success);
                gene3Success.Add(genResult3.success);

                ig1.NextStep();
                ig2.NextStep();
                ig3.NextStep();
            }

            // Assert
            Assert.AreEqual(rounds, gene1Objects.Count);
            Assert.AreEqual(rounds, gene2Objects.Count);
            Assert.AreEqual(rounds, gene3Objects.Count);

            Assert.AreEqual(rounds, gene1Success.Count);
            Assert.AreEqual(rounds, gene2Success.Count);
            Assert.AreEqual(rounds, gene3Success.Count);

            CollectionAssert.AllItemsAreInstancesOfType(gene1Objects, longType, "There should be only longs generated");
            CollectionAssert.AllItemsAreInstancesOfType(gene2Objects, longType, "There should be only longs generated");
            CollectionAssert.AllItemsAreInstancesOfType(gene3Objects, longType, "There should be only longs generated");

            var rangeTemp = ig1.GetRange();

            foreach (object val in gene1Objects)
            {
                Assert.GreaterOrEqual((long)val, (long)rangeTemp.minRangeInclusive);
                Assert.Less((long)val, (long)rangeTemp.maxRangeExclusive);
            }

            Assert.AreEqual(range2.min, (long)ig2.GetRange().minRangeInclusive, "Range min should have been parsed correctly");
            Assert.AreEqual(range2.max, (long)ig2.GetRange().maxRangeExclusive, "Range max should have been parsed correctly");

            foreach (object val in gene2Objects)
            {
                Assert.GreaterOrEqual((long)val, range2.min);
                Assert.Less((long)val, range2.max);
            }
        }
Exemplo n.º 12
0
        public void DatesEmailsTexts_InstancesOfType()
        {
            var type = typeof(DateTime);

            CollectionAssert.AllItemsAreInstancesOfType(sc.DatesEmailTexts, type);
        }
        public void Check_Pure_Gps_Observations_File_With_StoreMode()
        {
            var parser = new RinexObsParser("pure_gps.16o", ParseType.StoreData);

            parser.Parse();
            Assert.IsTrue(parser.RinexType == RinexType.Obs);
            Assert.IsTrue(parser.ObsHeader.ObsHeaderData.SatelliteSystem == SatelliteSystem.Gps);
            Assert.IsTrue(parser.ObsHeader.ObsHeaderData.GnssTimeSystem == GnssTimeSystem.Gps);
            Assert.IsTrue(parser.ObservationRecords.Count == 19);

            var metaData = parser.ObsHeader.ObsHeaderData.ObsMetaData;

            CheckObservations(metaData, SatelliteSystem.Gps, new[]
            {
                ObservationCode.C1C, ObservationCode.L1C, ObservationCode.D1C,
                ObservationCode.S1C, ObservationCode.C2S, ObservationCode.L2S,
                ObservationCode.D2S, ObservationCode.S2S, ObservationCode.C2W,
                ObservationCode.L2W, ObservationCode.D2W, ObservationCode.S2W,
                ObservationCode.C5Q, ObservationCode.L5Q, ObservationCode.D5Q,
                ObservationCode.S5Q
            });

            var sysPhaseShift = parser.ObsHeader.ObsHeaderData.PhaseShiftDict;

            Assert.IsTrue(sysPhaseShift.ContainsKey(SatelliteSystem.Gps));

            var temp = sysPhaseShift[SatelliteSystem.Gps].SingleOrDefault(t => t.ObservationCode == ObservationCode.L2S);

            Assert.IsTrue(temp != null);
            Assert.IsTrue(temp.ObservationCode == ObservationCode.L2S);
            Assert.IsTrue(Math.Abs(temp.CorrectionCycles - -0.25) <= Double.Epsilon);

            temp = sysPhaseShift[SatelliteSystem.Gps].SingleOrDefault(t => t.ObservationCode == ObservationCode.L2X);
            Assert.IsTrue(temp != null);
            Assert.IsTrue(temp.ObservationCode == ObservationCode.L2X);
            Assert.IsTrue(Math.Abs(temp.CorrectionCycles - -0.25) <= Double.Epsilon);


            var gpsObsData = parser.GetSatellitesObservations <GpsSatellite>();

            CollectionAssert.AllItemsAreNotNull(gpsObsData.Values as ICollection);
            CollectionAssert.AllItemsAreInstancesOfType(gpsObsData.Values.SelectMany(t => t).ToArray(),
                                                        typeof(SatelliteObs <GpsSatellite>));

            var observedSatellites = parser.GetObservedSatellites();

            Assert.IsTrue(observedSatellites.ContainsKey(SatelliteSystem.Gps));
            var galPrns = observedSatellites[SatelliteSystem.Gps];

            CollectionAssert.AreEqual(galPrns.SatellitePrn <GpsSatellite>().ToList(),
                                      new[]
            {
                GpsSatellite.G05, GpsSatellite.G12, GpsSatellite.G14, GpsSatellite.G15, GpsSatellite.G18,
                GpsSatellite.G20, GpsSatellite.G21, GpsSatellite.G24, GpsSatellite.G25, GpsSatellite.G29,
                GpsSatellite.G31, GpsSatellite.G32
            });


            Assert.IsTrue(gpsObsData.Count == 19);
            foreach (var satData in gpsObsData.Values)
            {
                Assert.IsTrue(satData.Count == 12);
            }
        }
        public void Check_Pure_Glo_Observations_File_With_StoreMode()
        {
            var parser = new RinexObsParser("pure_glo.16o", ParseType.StoreData);

            parser.Parse();
            Assert.IsTrue(parser.RinexType == RinexType.Obs);
            Assert.IsTrue(parser.ObsHeader.ObsHeaderData.SatelliteSystem == SatelliteSystem.Glo);
            Assert.IsTrue(parser.ObsHeader.ObsHeaderData.GnssTimeSystem == GnssTimeSystem.Glo);
            Assert.IsTrue(parser.ObservationRecords.Count == 19);

            var metaData = parser.ObsHeader.ObsHeaderData.ObsMetaData;

            CheckObservations(metaData, SatelliteSystem.Glo, new[]
            {
                ObservationCode.C1C, ObservationCode.L1C, ObservationCode.D1C,
                ObservationCode.S1C, ObservationCode.C2P, ObservationCode.L2P,
                ObservationCode.D2P, ObservationCode.S2P
            });

            var phaseCorrections = parser.ObsHeader.ObsHeaderData.GloPhaseBiasCor;

            Assert.IsTrue(phaseCorrections.ContainsKey(ObservationCode.C1C));
            Assert.IsTrue(Math.Abs(phaseCorrections[ObservationCode.C1C] - -71.940) < Double.Epsilon);

            Assert.IsTrue(phaseCorrections.ContainsKey(ObservationCode.C1P));
            Assert.IsTrue(Math.Abs(phaseCorrections[ObservationCode.C1P] - -71.940) < Double.Epsilon);

            Assert.IsTrue(phaseCorrections.ContainsKey(ObservationCode.C2C));
            Assert.IsTrue(Math.Abs(phaseCorrections[ObservationCode.C2C] - -71.940) < Double.Epsilon);

            Assert.IsTrue(phaseCorrections.ContainsKey(ObservationCode.C2P));
            Assert.IsTrue(Math.Abs(phaseCorrections[ObservationCode.C2P] - -71.940) < Double.Epsilon);

            var slotFrqKeys   = parser.ObsHeader.ObsHeaderData.GloSlotFreqDict.Keys;
            var slotFrqValues = parser.ObsHeader.ObsHeaderData.GloSlotFreqDict.Values;

            var expected = new List <GloSatellite>();
            var temp     = Enum.GetValues(typeof(GloSatellite));

            for (var i = 0; i < 24; i++)
            {
                expected.Add((GloSatellite)temp.GetValue(i));
            }

            CollectionAssert.AreEqual(expected, slotFrqKeys);
            CollectionAssert.AreEqual(
                new[] { 1, -4, 5, 6, 1, -4, 5, 6, -6, -7, 0, -1, -2, -7, 0, -1, 4, -3, 3, 2, 4, -3, 3, 2 }, slotFrqValues);

            var gloSatData = parser.GetSatellitesObservations <GloSatellite>();

            CollectionAssert.AllItemsAreNotNull(gloSatData.Values as ICollection);
            CollectionAssert.AllItemsAreInstancesOfType(gloSatData.Values.SelectMany(t => t).ToArray(),
                                                        typeof(SatelliteObs <GloSatellite>));


            var observedSatellites = parser.GetObservedSatellites();

            Assert.IsTrue(observedSatellites.ContainsKey(SatelliteSystem.Glo));
            var galPrns = observedSatellites[SatelliteSystem.Glo];

            CollectionAssert.AreEqual(galPrns.SatellitePrn <GloSatellite>().ToList(),
                                      new[]
            {
                GloSatellite.R01, GloSatellite.R08, GloSatellite.R10, GloSatellite.R11, GloSatellite.R13,
                GloSatellite.R22, GloSatellite.R23, GloSatellite.R24
            });


            Assert.IsTrue(gloSatData.Count == 19);
            foreach (var satData in gloSatData.Values)
            {
                Assert.IsTrue(satData.Count == 8 || satData.Count == 7);
            }
        }
        public void GetAppPoolReturnsNonEmpyListOfServer()
        {
            var list = _iis.GetApplicationPools(new[] { "itpr1web23", "itpr1web34" }, creds.UserName, creds.Password);

            CollectionAssert.AllItemsAreInstancesOfType(list, typeof(Server));
        }
Exemplo n.º 16
0
 //Grid holds 3x3 spaces
 public void Spaces()
 {
     CollectionAssert.AllItemsAreInstancesOfType(grid.Spaces, typeof(Space));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Tests whether all elements in the specified collection are instances
 /// of the expected type and throws an exception if the expected type is
 /// not in the inheritance hierarchy of one or more of the elements.
 /// </summary>
 /// <param name="collectionAssert"></param>
 /// <param name="collection">
 /// The collection containing elements the test expects to be of the
 /// specified type.
 /// </param>
 /// <param name="expectedType">
 /// The expected type of each element of <paramref name="collection"/>.
 /// </param>
 /// <param name="message">
 /// The message to include in the exception when an element in
 /// <paramref name="collection"/> is not an instance of
 /// <paramref name="expectedType"/>. The message is shown in test results.
 /// </param>
 /// <exception cref="AssertFailedException">
 /// Thrown if an element in <paramref name="collection"/> is null or
 /// <paramref name="expectedType"/> is not in the inheritance hierarchy
 /// of an element in <paramref name="collection"/>.
 /// </exception>
 public static CollectionAssert AllItemsAreInstancesOfTypeT(this CollectionAssert collectionAssert, ICollection collection, Type expectedType, string message = "")
 {
     CollectionAssert.AllItemsAreInstancesOfType(collection, expectedType, message, null);
     return(collectionAssert);
 }
Exemplo n.º 18
0
        public void AllSavingsAccount_OnSucess_ShouldGetOnlySavingsAccounts()
        {
            var actual = target.GetAllSavingsAccounts();

            CollectionAssert.AllItemsAreInstancesOfType(actual, typeof(Saving));
        }
        public void GetAllTournaments()
        {
            var tournaments = accessor.GetAllTournaments();

            CollectionAssert.AllItemsAreInstancesOfType(tournaments.ToList(), typeof(JsonTournament));
        }
Exemplo n.º 20
0
        public void AllCurrentAccount_OnSucess_ShouldGetOnlyCurrentAccounts()
        {
            var actual = target.GetAllCurrentAccounts();

            CollectionAssert.AllItemsAreInstancesOfType(actual, typeof(Current));
        }
        public void Parse_ValidStructuresStabilityData_SetsOutputAsExpected()
        {
            // Setup
            string path   = Path.Combine(testDirectory, "ValidStructuresStabilityOutputSection1");
            var    parser = new IllustrationPointsParser();

            // Call
            parser.Parse(path, 1);

            // Assert
            GeneralResult generalResult = parser.Output;

            Assert.NotNull(generalResult);
            Assert.NotNull(generalResult.GoverningWindDirection);
            Assert.AreEqual(30, generalResult.GoverningWindDirection.Angle);
            Assert.AreEqual(" 30", generalResult.GoverningWindDirection.Name);
            Assert.AreEqual(-3.74187, generalResult.Beta);
            Assert.AreEqual(44, generalResult.Stochasts.Count());

            Dictionary <WindDirectionClosingSituation, IllustrationPointTreeNode> illustrationPointNodes = generalResult.IllustrationPoints;

            Assert.AreEqual(12, illustrationPointNodes.Count);
            CollectionAssert.AllItemsAreInstancesOfType(illustrationPointNodes.Values.Select(ip => ip.Data), typeof(FaultTreeIllustrationPoint));

            ICollection <FaultTreeIllustrationPoint>    faultTrees    = new List <FaultTreeIllustrationPoint>();
            ICollection <SubMechanismIllustrationPoint> subMechanisms = new List <SubMechanismIllustrationPoint>();

            GetAllNodes(illustrationPointNodes.Values.First(), faultTrees, subMechanisms);

            Assert.AreEqual(11, faultTrees.Count);
            Assert.AreEqual(new[]
            {
                CombinationType.Or,
                CombinationType.Or,
                CombinationType.And,
                CombinationType.And,
                CombinationType.Or,
                CombinationType.And,
                CombinationType.And,
                CombinationType.And,
                CombinationType.Or,
                CombinationType.And,
                CombinationType.And
            }, faultTrees.Select(f => f.CombinationType));

            Assert.AreEqual(12, subMechanisms.Count);
            SubMechanismIllustrationPoint subMechanismIllustrationPoint = subMechanisms.First();

            Assert.AreEqual("Bezwijken kunstwerk als gevolg van erosie bodem", subMechanismIllustrationPoint.Name);
            Assert.AreEqual(-7.94268, subMechanismIllustrationPoint.Beta);
            Assert.AreEqual(new[]
            {
                Tuple.Create("Faalkans gegeven erosie bodem", -1.0, 4383.0, -7.94268)
            }, subMechanismIllustrationPoint.Stochasts.Select(s => Tuple.Create(s.Name, s.Alpha, s.Duration, s.Realization)));
            CollectionAssert.IsEmpty(subMechanismIllustrationPoint.Results);

            FaultTreeIllustrationPoint faultTreeIllustrationPoint = faultTrees.First();

            Assert.AreEqual("Bezwijken kunstwerk als gevolg van erosie bodem", subMechanismIllustrationPoint.Name);
            Assert.AreEqual(0.508398, faultTreeIllustrationPoint.Beta);
            Assert.AreEqual(CombinationType.Or, faultTreeIllustrationPoint.CombinationType);
            Assert.AreEqual(44, faultTreeIllustrationPoint.Stochasts.Count());
            Assert.AreEqual(new[]
            {
                Tuple.Create("Kerende hoogte", 0.0, 4383.0),
                Tuple.Create("Modelfactor voor onvolkomen stroming", 0.0, 4383.0),
                Tuple.Create("Drempelhoogte", 0.0, 4383.0),
                Tuple.Create("Afvoercoefficient", -3.91812E-07, 4383.0),
                Tuple.Create("Doorstroomoppervlak", 3.93695E-08, 4383.0),
                Tuple.Create("Lineaire belastingschematisering constructieve sterkte", 0.214064, 4383.0)
            }, faultTreeIllustrationPoint.Stochasts.Take(6).Select(s => Tuple.Create(s.Name, s.Alpha, s.Duration)));
        }
Exemplo n.º 22
0
 public void all_items_same_type()
 {
     CollectionAssert.AllItemsAreInstancesOfType(_userList, typeof(string));
 }
Exemplo n.º 23
0
        public void GetAllCurrentAccounts_OnSuccess_CheckType()
        {
            var actual = target.GetAllCurrentAccounts();

            CollectionAssert.AllItemsAreInstancesOfType(actual, typeof(Current));
        }
Exemplo n.º 24
0
 public void Game_with_all_enemies_Added()
 {
     CollectionAssert.AllItemsAreInstancesOfType(g.Enemys, typeof(Enemy));
 }
Exemplo n.º 25
0
        public void ItShouldMarkAllResultsAsPending()
        {
            IEnumerable <Result> enumerable = _results.First().ScenarioResults.First().StepResults.Select(result => result.Result).ToList();

            CollectionAssert.AllItemsAreInstancesOfType(enumerable, typeof(Pending));
        }
        public void GenerateCalculationItemsStructure_OneSurfaceLineIntersectingSoilModelOneSurfaceLineNoIntersection_ReturnOneGroupsWithProfilesAndLogOneWarning()
        {
            // Setup
            var soilProfile1 = new PipingStochasticSoilProfile(
                1.0, new PipingSoilProfile("Profile 1", -10.0, new[]
            {
                new PipingSoilLayer(-5.0),
                new PipingSoilLayer(-2.0),
                new PipingSoilLayer(1.0)
            }, SoilProfileType.SoilProfile1D)
                );
            var soilProfile2 = new PipingStochasticSoilProfile(
                1.0, new PipingSoilProfile("Profile 2", -8.0, new[]
            {
                new PipingSoilLayer(-4.0),
                new PipingSoilLayer(0.0),
                new PipingSoilLayer(4.0)
            }, SoilProfileType.SoilProfile1D)
                );

            const double y          = 1.1;
            var          soilModel1 = new PipingStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, y),
                new Point2D(2.0, y)
            }, new[]
            {
                soilProfile1,
                soilProfile2
            });

            var soilModel2 = new PipingStochasticSoilModel("A", new[]
            {
                new Point2D(3.0, y),
                new Point2D(4.0, y)
            }, new[]
            {
                soilProfile2
            });

            PipingStochasticSoilModel[] availableSoilModels =
            {
                soilModel1,
                soilModel2
            };

            const string surfaceLineName1 = "surface line 1";
            const string surfaceLineName2 = "surface line 2";
            var          surfaceLine1     = new PipingSurfaceLine(surfaceLineName1);

            surfaceLine1.SetGeometry(new[]
            {
                new Point3D(2.5, y, 1.0),
                new Point3D(0.0, y, 0.0)
            });
            var surfaceLine2 = new PipingSurfaceLine(surfaceLineName2);

            surfaceLine2.SetGeometry(new[]
            {
                new Point3D(5.0, y, 1.0),
                new Point3D(6.4, y, 0.0)
            });

            PipingSurfaceLine[] surfaceLines =
            {
                surfaceLine1,
                surfaceLine2
            };

            ICalculationBase[] result = null;

            // Call
            void Call()
            {
                result = PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure(
                    surfaceLines, true, true, availableSoilModels).ToArray();
            }

            // Assert
            var expectedMessage = Tuple.Create(
                $"Geen ondergrondschematisaties gevonden voor profielschematisatie '{surfaceLineName2}'. De profielschematisatie is overgeslagen.",
                LogLevelConstant.Warn);

            TestHelper.AssertLogMessageWithLevelIsGenerated(Call, expectedMessage, 1);

            Assert.AreEqual(1, result.Length);
            var calculationGroup1 = (CalculationGroup)result.First(g => g.Name == surfaceLineName1);

            Assert.AreEqual(4, calculationGroup1.Children.Count);
            CollectionAssert.AllItemsAreInstancesOfType(calculationGroup1.Children, typeof(IPipingCalculationScenario <PipingInput>));

            AssertCalculationScenario((SemiProbabilisticPipingCalculationScenario)calculationGroup1.Children[0], soilProfile1, surfaceLine1);
            AssertCalculationScenario((ProbabilisticPipingCalculationScenario)calculationGroup1.Children[1], soilProfile1, surfaceLine1);
            AssertCalculationScenario((SemiProbabilisticPipingCalculationScenario)calculationGroup1.Children[2], soilProfile2, surfaceLine1);
            AssertCalculationScenario((ProbabilisticPipingCalculationScenario)calculationGroup1.Children[3], soilProfile2, surfaceLine1);
        }
Exemplo n.º 27
0
 public void IsEveryAccountPropperType()
 {
     CollectionAssert.AllItemsAreInstancesOfType(BGZ.accounts, typeof(Account));
 }
Exemplo n.º 28
0
 public void AllItemsMustSameType()
 {
     CollectionAssert.AllItemsAreInstancesOfType(_users, typeof(string));
 }
 public void CheckIfItemsAreCategories()
 {
     CollectionAssert.AllItemsAreInstancesOfType(_categoryService.GetAll().ToList(), typeof(Category));
 }
Exemplo n.º 30
0
        public void MapArchiveModel_ReturnAListOfArchives()
        {
            List <Archive> archives = _sut.MapArchiveModel(Mother.GetListOfFiveDateTimes(), Mother.GetFiveSimpleBlogPosts());

            CollectionAssert.AllItemsAreInstancesOfType(archives, typeof(Archive));
        }