public void DiscardsDuplicates()
        {
            var mockScanner = new Mock <FileScanner>();

            mockScanner.Setup(p => p.ScanCode(It.IsAny <string>(), It.IsAny <ScanResults>(), It.IsAny <string>())).Returns((
                                                                                                                               string a, ScanResults result, string b) =>
            {
                result.FoundClasses.Add(new SqlSchema("Schema", "PathA"));
                result.FoundClasses.Add(new SqlSchema("Schema", "PathB"));
                result.FoundClasses.Add(new SqlSchema("Schema", "PathB"));

                result.FoundPotentialTests.Add(new SqlProcedure(new SqlObjectName()
                {
                    Object = "test", Schema = "Schema"
                }, "Patha", 0, 100, 1));
                result.FoundPotentialTests.Add(new SqlProcedure(new SqlObjectName()
                {
                    Object = "test", Schema = "Schema"
                }, "Pathb", 0, 100, 1));
                return(result);
            });

            var mockFileReader = new Mock <IFileReader>();

            mockFileReader.Setup(p => p.ReadAll(It.IsAny <string>())).Returns("Blah");
            mockFileReader.Setup(p => p.GetLastWriteTimeUtc(It.IsAny <string>())).Returns(DateTime.MaxValue);

            var testCache = new TestCache(mockScanner.Object, mockFileReader.Object);

            testCache.AddPath("path");
            Assert.AreEqual(1, testCache.GetTests().Count);
        }
示例#2
0
        public void TestCache()
        {
            TestCache test = new TestCache();

            test.Add("ProductCode1", CommonTestData.GetTestData("1"));
            test.Add("ProductCode2", CommonTestData.GetTestData("2"));
            test.Add("ProductCode3", CommonTestData.GetTestData("3"));
            Product p;

            test.TryGetValue("ProductCode2", out p);
            Assert.AreEqual(p.Code, "ProductCode2");
            test.Clear();
            Assert.AreEqual(test.Count, 0);

            test.Add("ProductCode1", CommonTestData.GetTestData("1"));
            test.Add("ProductCode2", CommonTestData.GetTestData("2"));
            test.Add("ProductCode3", CommonTestData.GetTestData("3"));
            Assert.AreEqual(test.ContainsKey("ProductCode1"), true);
            test.TryGetValue("ProductCode3", out p);
            Assert.AreEqual(test.Values.Contains(p), true);

            test.Remove("ProductCode1");
            Assert.AreEqual(test.ContainsKey("ProductCode1"), false);
            Assert.AreEqual(test.Count, 2);
        }