Esempio n. 1
0
        public void ThreadWorkerStoresReduceResults()
        {
            var reducerCodeFileName = new Uri("file:///SampleReducer.cs");

            var keys = ReducerTests.CreateTwoKeyFileSet(this.storage);
            TestHelpers.LoadToStorage(@"..\..\SampleReducer.cs", reducerCodeFileName, this.storage);
            var worker = new ThreadWorker(this.storage, 1);

            worker.Reduce(Base64.Encode("k1"), reducerCodeFileName);
            worker.Join();

            var result = default(string);
            var regex = new Regex(string.Format("^" + Core.Properties.Settings.Default.ReduceOutputFileName + "$", @"(?<Key>.+)", "[0-9]+", RegexExtensions.GuidRegexString));
            var uris = this.storage.ListFiles();
            foreach (var uri in uris)
            {
                var fileName = this.storage.GetFileName(uri);
                if (regex.IsMatch(fileName))
                {
                    var key = regex.Match(fileName).Groups["Key"].Value;
                    if (Base64.Decode(key) == "k1")
                    {
                        result = this.storage.Read(fileName);
                    }
                }
            }

            result.ShouldBe("3");
        }