示例#1
0
        public void TestConcurrencyWriteAccess()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{99D73F8B-587A-4869-97AE-4A7185D88AC9}");
            Utils.GenerateSourceFile("input2", "{9FEABA51-4CE6-4DB0-9866-45A7492FD1B7}");
            var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1"));

            var builder            = Utils.CreateBuilder();
            CommandBuildStep step1 = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep }
            });
            CommandBuildStep step2 = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input2")), OutputUrl = "/db/url2", InputDependencies = { inputDep }
            });

            builder.Root.Add(new WaitBuildStep());
            CommandBuildStep concurrencyStep1 = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url", InputDependencies = { inputDep }
            });
            CommandBuildStep concurrencyStep2 = builder.Root.Add(new InputOutputCommand {
                Delay = 150, Source = new ObjectUrl(UrlType.Internal, "/db/url2"), OutputUrl = "/db/url", InputDependencies = { inputDep }
            });

            BuildStep.LinkBuildSteps(step1, concurrencyStep1);
            BuildStep.LinkBuildSteps(step2, concurrencyStep2);

            Utils.StartCapturingLog();
            builder.Run(Builder.Mode.Build);
            string log = Utils.StopCapturingLog();

            Assert.That(log.Contains("Commands InputOutputCommand /db/url2 > /db/url and InputOutputCommand /db/url1 > /db/url are both writing /db/url at the same time"));
        }
示例#2
0
        public void TestConcurrencyReadWriteAccess()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{99D73F8B-587A-4869-97AE-4A7185D88AC9}");
            var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1"));

            var builder           = Utils.CreateBuilder();
            CommandBuildStep step = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep }
            });

            builder.Root.Add(new WaitBuildStep());
            CommandBuildStep concurrencyStep1 = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url1", InputDependencies = { inputDep }
            });
            CommandBuildStep concurrencyStep2 = builder.Root.Add(new InputOutputCommand {
                Delay = 150, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url2", InputDependencies = { inputDep }
            });

            BuildStep.LinkBuildSteps(step, concurrencyStep1);
            BuildStep.LinkBuildSteps(step, concurrencyStep2);

            Utils.StartCapturingLog();
            builder.Run(Builder.Mode.Build);
            string log = Utils.StopCapturingLog();

            Assert.That(log.Contains("Command InputOutputCommand /db/url1 > /db/url1 is writing /db/url1 while command InputOutputCommand /db/url1 > /db/url2 is reading it"));
        }