public void GetContents_FindsFile_ReturnsOneFileSystemObject() { // Arrange List <FileSystemObject> expected = new List <FileSystemObject> { new FileSystemObject { Name = "appsettings.json", Type = FileSystemObjectType.File.ToString(), Path = "App/appsettings.json", Encoding = "Unicode (UTF-8)" }, }; int expectedCount = 1; HttpContext httpContext = GetHttpContextForTestUser("testUser"); Mock <IHttpContextAccessor> httpContextAccessorMock = new Mock <IHttpContextAccessor>(); httpContextAccessorMock.Setup(s => s.HttpContext).Returns(httpContext); RepositorySI sut = GetServiceForTest(httpContextAccessorMock); // Act List <FileSystemObject> actual = sut.GetContents("ttd", "apps-test", "App/appsettings.json"); // Assert Assert.Equal(expected.First().Type, actual.First().Type); Assert.Equal(expectedCount, actual.Count); }
public void GetContents_FindsFolder_ReturnsListOfFileSystemObjects() { // Arrange List <FileSystemObject> expected = new List <FileSystemObject> { new FileSystemObject { Name = "App", Type = FileSystemObjectType.Dir.ToString(), Path = "App" }, new FileSystemObject { Name = "App.sln", Type = FileSystemObjectType.File.ToString(), Path = "App.sln", Encoding = "Unicode (UTF-8)" }, }; int expectedCount = 2; RepositorySI sut = GetServiceForTest("testUser"); // Act List <FileSystemObject> actual = sut.GetContents("ttd", "apps-test"); // Assert Assert.Equal(expected.First().Type, actual.First().Type); Assert.Equal(expectedCount, actual.Count); }
public void GetContents_LocalCloneOfRepositoryNotAvailable_ReturnsNull() { // Arrange RepositorySI sut = GetServiceForTest("testUser"); // Act List <FileSystemObject> actual = sut.GetContents("ttd", "test-apps"); // Assert Assert.Null(actual); }
public void GetContents_LocalCloneOfRepositoryNotAvailable_ReturnsNull() { // Arrange HttpContext httpContext = GetHttpContextForTestUser("testUser"); Mock <IHttpContextAccessor> httpContextAccessorMock = new Mock <IHttpContextAccessor>(); httpContextAccessorMock.Setup(s => s.HttpContext).Returns(httpContext); RepositorySI sut = GetServiceForTest(httpContextAccessorMock); // Act List <FileSystemObject> actual = sut.GetContents("ttd", "test-apps"); // Assert Assert.Null(actual); }