예제 #1
0
파일: UnitTest3.cs 프로젝트: lsoft/Proxy
        public void TestClosePerformanceSession0()
        {
            var rf = new Mock<IPerformanceRecordFactory>();
            rf.Setup(a => a.CreateRecord(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(new Mock<IPerformanceRecord>().Object);
            rf.Setup(a => a.CreateChildRecord(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IPerformanceRecord>()))
                .Returns(new Mock<IPerformanceRecord>().Object);

            var sf = new Mock<IPerformanceSaver>();

            var pc = new PerformanceTelemetry.Container.PerformanceContainer(
                new EmptyLoggerAdapter(),
                rf.Object,
                sf.Object);

            var r = pc.OpenPerformanceSession(
                1,
                string.Empty,
                string.Empty);

            Assert.IsNotNull(r);

            pc.ClosePerformanceSession(1, r);


        }
예제 #2
0
파일: UnitTest2.cs 프로젝트: lsoft/Proxy
        public void TestOpenPerformanceSession1()
        {
            var r1 = new Mock<IPerformanceRecord>();

            var r0 = new Mock<IPerformanceRecord>();
            r0.Setup(a => a.GetDeepestActiveRecord())
                .Returns(r0.Object);
            r0.Setup(a => a.CreateChild(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(r1.Object);

            var rf = new Mock<IPerformanceRecordFactory>();
            rf.Setup(a => a.CreateRecord(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(r0.Object);
            rf.Setup(a => a.CreateChildRecord(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IPerformanceRecord>()))
                .Throws(new InternalTestFailureException("этого вызова быть не должно"));

            var sf = new Mock<IPerformanceSaver>();

            var pc = new PerformanceTelemetry.Container.PerformanceContainer(
                new EmptyLoggerAdapter(),
                rf.Object,
                sf.Object);

            var r_0 = pc.OpenPerformanceSession(
                1,
                string.Empty,
                string.Empty);

            var r_1 = pc.OpenPerformanceSession(
                1,
                string.Empty,
                string.Empty);

            Assert.IsNotNull(r_0);
            Assert.IsNotNull(r_1);

            Assert.AreSame(r0.Object, r_0);
            Assert.AreSame(r1.Object, r_1);

        }