Exemple #1
0
        public void GetMatchingTargets_ReturnsOnlySetupsThatTargetQueriedMethod(int indexToTest)
        {
            ReadOnlyCollection <IRewriteTarget> setups = new List <IRewriteTarget>
            {
                TestDataFactory.CreateSetupTarget(() => Console.WriteLine()),
                TestDataFactory.CreateSetupTarget(() => Console.ReadLine())
            }.AsReadOnly();

            var subject = new RewriteTargetMatcher(_methodImporterMock.Object, setups);
            var result  = subject.GetMatchingTargets(CecilUtility.Import(setups[indexToTest].Methods[0]));

            Assert.AreEqual(setups[indexToTest], result.Single());
        }
Exemple #2
0
        public void GetMatchingTargets_ReturnsAllSetupsThatTargetQueriedMethod()
        {
            ReadOnlyCollection <IRewriteTarget> setups = new List <IRewriteTarget>
            {
                TestDataFactory.CreateSetupTarget(() => Console.WriteLine()),
                TestDataFactory.CreateSetupTarget(() => Console.ReadLine()),
                TestDataFactory.CreateSetupTarget(() => Console.WriteLine())
            }.AsReadOnly();

            var subject = new RewriteTargetMatcher(_methodImporterMock.Object, setups);
            var result  = subject.GetMatchingTargets(CecilUtility.Import(setups[0].Methods[0]));

            Assert.AreEqual(2, result.Count());
            Assert.IsTrue(result.All(setup => setup.Methods[0] == setups[0].Methods[0]));
        }