public bool Equals(FileContentData other) { if (other == null) { return(false); } if (this.Length != other.Length) { return(false); } if (this.Data == other.Data) { return(true); } for (long i = 0; i < Length; i++) { if (this.Data[i] != other.Data[i]) { return(false); } } return(true); }
public void Equals_DifferentData_ReturnsFalse() { var x = new FileContentData(new byte[] { 1, 2, 3, }, 4); var y = new FileContentData(new byte[] { 2, 3, 4, }, 3); Assert.IsFalse(x.Equals(y)); Assert.IsFalse(y.Equals(x)); }
public void Equals_SameDataDifferentLength_ReturnsFalse() { var x = new FileContentData(new byte[] { 1, 2, 3, }, 2); var y = new FileContentData(new byte[] { 1, 2, 3, }, 3); Assert.IsFalse(x.Equals(y)); Assert.IsFalse(y.Equals(x)); }
public void Equals_SameDataAndLength_ReturnsTrue() { var x = new FileContentData(new byte[] { 1, 2, 3, }, 2); var y = new FileContentData(new byte[] { 1, 2, }, 2); Assert.IsTrue(x.Equals(y)); Assert.IsTrue(y.Equals(x)); }
private void WriteData(FileContentData data) { if (data.Length > int.MaxValue) { throw new NotSupportedException("Import cannot currently cope with files larger than 2 GB"); } WriteLine("data {0}", data.Length); m_stream.Write(data.Data, 0, (int)data.Length); m_stream.Write(m_newLine, 0, m_newLine.Length); }
public bool Equals(FileContentData other) { if (other == null) return false; if (this.Length != other.Length) return false; if (this.Data == other.Data) return true; for (long i = 0; i < Length; i++) { if (this.Data[i] != other.Data[i]) return false; } return true; }
public void GetCvsRevision_ReturnsExistingFileIfPresent() { var f = new FileRevision(new FileInfo("file.txt"), Revision.Create("1.1"), mergepoint: Revision.Empty, time: DateTime.Now, author: "fred", commitId: "c1"); var contents = new FileContentData(new byte[] { 1, 2, 3, 4 }, 4); var repo1 = MockRepository.GenerateStub<ICvsRepository>(); repo1.Stub(r => r.GetCvsRevision(f)).Return(new FileContent("file.txt", contents)); var cache1 = new CvsRepositoryCache(m_temp.Path, repo1); cache1.GetCvsRevision(f); // create a second cache var repo2 = MockRepository.GenerateMock<ICvsRepository>(); var cache2 = new CvsRepositoryCache(m_temp.Path, repo1); var data = cache2.GetCvsRevision(f); repo2.AssertWasNotCalled(r => r.GetCvsRevision(f)); Assert.AreNotSame(data.Data, contents); Assert.IsTrue(data.Data.Equals(contents)); }
private static FileContent CreateMockContent(FileRevision f) { var data = Encoding.UTF8.GetBytes(String.Format("{0} r{1}", f.File.Name, f.Revision.ToString())); var content = new FileContentData(data, data.Length); return new FileContent(f.File.Name, content); }
public void Equals_Null_ReturnsFalse() { var x = new FileContentData(new byte[] { 1, 2, 3, }, 2); Assert.IsFalse(x.Equals(null)); }
public void Equals_SameInstance_ReturnsTrue() { var x = new FileContentData(new byte[] { 1, 2, 3, }, 2); Assert.IsTrue(x.Equals(x)); }
private void WriteData(FileContentData data) { if (data.Length > int.MaxValue) throw new NotSupportedException("Import cannot currently cope with files larger than 2 GB"); WriteLine("data {0}", data.Length); m_stream.Write(data.Data, 0, (int)data.Length); m_stream.Write(m_newLine, 0, m_newLine.Length); }