public async Task ArchiveAsync_CodeFileEntityDoesNotExist_ReturnsNull() { // Arrange _codeFileTable .ExecuteAsync(Arg.Any <TableOperation>()) .Returns(new TableResult { Result = null }); var codeFileRepository = new CodeFileRepository(_codeFileTable); // Act var actualResult = await codeFileRepository.ArchiveAsync(TestFilePath); // Assert Assert.AreEqual(null, actualResult); }
public async Task ArchiveAsync_ArchiveCodeFileEntity_ReturnsCorrectCodeFile() { // Arrange var codeFragmentsJson = @"[{ ""Identifier"":""test_identifier"", ""Content"":""test content"", ""Language"":""c_"", ""Platform"":""_net"", ""Codename"":""test_identifier_net"" }]"; var expectedCodeFragment = new CodeFragment { Identifier = "test_identifier", Content = "test content", Language = "c_", Platform = "_net", }; var expectedResult = new CodeFile { FilePath = TestFilePath, CodeFragments = new List <CodeFragment> { expectedCodeFragment } }; var archivedCodeFileEntity = new CodeFileEntity { IsArchived = true, CodeFragments = codeFragmentsJson }; _codeFileTable .ExecuteAsync(TableOperation.InsertOrReplace(archivedCodeFileEntity)) .Returns(new TableResult { Result = new CodeFileEntity { IsArchived = true, CodeFragments = codeFragmentsJson, } }); _codeFileTable .ExecuteAsync(Arg.Any <TableOperation>()) .Returns(new TableResult { Result = new CodeFileEntity { IsArchived = false, Path = TestFilePath, CodeFragments = codeFragmentsJson, } }); var codeFileRepository = new CodeFileRepository(_codeFileTable); // Act var actualResult = await codeFileRepository.ArchiveAsync(TestFilePath); // Assert Assert.That(actualResult, Is.EqualTo(expectedResult).UsingCodeFileComparer()); }