public void FileListing_Equals_Object_Expected_True() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; var expectedChildren = new Collection <IFileListing> { new FileListing { Name = "childNameOne" }, new FileListing { Name = "childNameTwo" } }; var mockFileListing = new Mock <IFileListing>(); mockFileListing.Setup(fileList => fileList.Name).Returns(expectedName); mockFileListing.Setup(fileList => fileList.FullName).Returns(expectedFullName); mockFileListing.Setup(fileList => fileList.IsDirectory).Returns(expectedIsDirectory); var fileListing = new FileListing(mockFileListing.Object) { Children = expectedChildren }; object fileListingObj = fileListing; var isEqual = fileListing.Equals(fileListingObj); Assert.IsTrue(isEqual); }
public void FileListing_Equals_FileListing_Expected_False() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; var mockFileListing = new Mock <IFileListing>(); mockFileListing.Setup(fileList => fileList.Name).Returns(expectedName); mockFileListing.Setup(fileList => fileList.FullName).Returns(expectedFullName); mockFileListing.Setup(fileList => fileList.IsDirectory).Returns(expectedIsDirectory); var fileListing = new FileListing(mockFileListing.Object); var mockFileListingDup = new Mock <IFileListing>(); mockFileListingDup.Setup(fileList => fileList.Name).Returns("testNewName"); mockFileListingDup.Setup(fileList => fileList.FullName).Returns(expectedFullName); mockFileListingDup.Setup(fileList => fileList.IsDirectory).Returns(expectedIsDirectory); var fileListingDup = new FileListing(mockFileListingDup.Object); var isEqual = fileListing.Equals(fileListingDup); Assert.IsFalse(isEqual); Assert.IsTrue(fileListing != fileListingDup); }
public void FileListing_Equals_Object_Null_Expected_False() { var fileListing = new FileListing(); const object fileListingObj = null; var isEqual = fileListing.Equals(fileListingObj); Assert.IsFalse(isEqual); }
public void FileListing_Equals_Object_GetType_Expected_False() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; var mockFileListing = new Mock <IFileListing>(); mockFileListing.Setup(fileList => fileList.Name).Returns(expectedName); mockFileListing.Setup(fileList => fileList.FullName).Returns(expectedFullName); mockFileListing.Setup(fileList => fileList.IsDirectory).Returns(expectedIsDirectory); var fileListing = new FileListing(mockFileListing.Object); var fileListingObj = new object(); var isEqual = fileListing.Equals(fileListingObj); Assert.IsFalse(isEqual); }