コード例 #1
0
ファイル: DiskStorageTest.cs プロジェクト: mxmsk/diff-sample
        public async Task LoadsReadyDiffFromDataDir(int diffId, DifferenceType type, int length)
        {
            var content = new DifferenceContent
            {
                Type    = type,
                Details = new[] {
                    new DifferenceDetail {
                        LeftLength = length
                    },
                    new DifferenceDetail {
                        RightLength = length
                    },
                }
            };
            var expectedFileName = Path.Combine(_DataDir,
                                                string.Concat(diffId.ToString(), ".diff"));

            File.WriteAllText(expectedFileName, JsonConvert.SerializeObject(content));
            try
            {
                var storage = new DiskStorage(_Options);
                var(diff, readiness) = await storage.LoadDiffAsync(diffId);

                readiness.Should().Be(DifferenceReadiness.Ready);

                diff.Type.Should().Be(type);
                diff.Details.ShouldAllBeEquivalentTo(content.Details,
                                                     opts => opts.WithStrictOrdering());
            }
            finally
            {
                File.Delete(expectedFileName);
            }
        }
コード例 #2
0
ファイル: DiskStorageTest.cs プロジェクト: mxmsk/diff-sample
        public async Task ReturnsNotFoundForDiffThatDoesntExistsInDataDirAlongWithSource()
        {
            var data = new byte[] { 3, 4, 5 };
            var expectedFileNames = new List <string>
            {
                Path.Combine(_DataDir, "10.left"),
                Path.Combine(_DataDir, "10.right"),
                Path.Combine(_DataDir, "10.diff"),
            };

            expectedFileNames.ForEach(File.Delete);

            var storage = new DiskStorage(_Options);

            var(_, readiness) = await storage.LoadDiffAsync(10);

            readiness.Should().Be(DifferenceReadiness.NotFound);
        }
コード例 #3
0
ファイル: DiskStorageTest.cs プロジェクト: mxmsk/diff-sample
        public async Task ReturnsNotReadyForDiffThatDoesntExistsInDataDirButHasSource(SourceSide side)
        {
            var data           = new byte[] { 3, 4, 5 };
            var sourceFileName = Path.Combine(_DataDir, string.Concat(
                                                  "11.", side.ToString().ToLowerInvariant()));

            File.WriteAllBytes(sourceFileName, data);
            try
            {
                var storage = new DiskStorage(_Options);
                var(_, readiness) = await storage.LoadDiffAsync(11);

                readiness.Should().Be(DifferenceReadiness.NotReady);
            }
            finally
            {
                File.Delete(sourceFileName);
            }
        }