Ejemplo n.º 1
0
        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);


        }
Ejemplo n.º 2
0
        public void TestCreate0()
        {
            var rf = new Mock<IPerformanceRecordFactory>();
            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);

        }
Ejemplo n.º 3
0
        public void TestDisposePerformanceSession0()
        {
            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);

            pc.Dispose();

            sf.Verify(j => j.Dispose(), Times.AtLeastOnce());
        }
Ejemplo n.º 4
0
        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);

        }
Ejemplo n.º 5
0
        public void TestCreate2()
        {
            var sf = new Mock<IPerformanceSaver>();

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

        }