public void Matches_checks_Length_if_specified_in_reference()
 {
     var reference1 = new FileReference("/dir1/file1", null, m_Length3);
     var reference2 = new FileReference("/dir1/file1", null, m_Length3 + 1);
     Assert.True(reference1.Matches(m_File3));
     Assert.False(reference2.Matches(m_File3));
 }
 public void Matches_checks_LastWriteTime_if_specified_in_reference()
 {
     var reference1 = new FileReference("/dir1/file1", m_LastWriteTime2);
     var reference2 = new FileReference("/dir1/file1", m_LastWriteTime2.AddMinutes(1));
     Assert.True(reference1.Matches(m_File2));
     Assert.False(reference2.Matches(m_File2));
 }
        public void Type_property_is_serialized_as_string()
        {
            var lastWriteTime = DateTime.Now;
            var oldVersion = new FileReference("/file1", lastWriteTime, 23);
            var newVersion = new FileReference("/file1", lastWriteTime.AddDays(1), 23 * 2);

            var syncAction = SyncAction.CreateReplaceFileSyncAction(Guid.NewGuid().ToString(), SyncActionState.Completed, 1, oldVersion, newVersion);

            var serialized = JObject.Parse(m_Instance.Serialize(syncAction));

            Assert.Equal(syncAction.Type.ToString(), serialized["Type"].ToString());
        }
        public void SyncAction_Roundtrip_Modified()
        {
            var lastWriteTime = DateTime.Now;

            var oldVersion = new FileReference("/file1", lastWriteTime, 23);
            var newVersion = new FileReference("/file1", lastWriteTime.AddDays(1), 23 * 2);            
            
            var expected = new SyncAction(ChangeType.Modified, oldVersion, newVersion, Guid.NewGuid(), Guid.NewGuid().ToString(), SyncActionState.Completed, 42);
            var actual = m_Instance.Deserialize(m_Instance.Serialize(expected));

            Assert.NotNull(actual);
            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Target, actual.Target);
            Assert.Equal(expected.FromVersion, actual.FromVersion);
            Assert.Equal(expected.ToVersion, actual.ToVersion);
            Assert.Equal(expected.State, actual.State);
            Assert.Equal(expected.SyncPointId, actual.SyncPointId);
        }
        public void SyncAction_Roundtrip_Deleted()
        {
            var fileReference = new FileReference("/file1", DateTime.Now, 23);

            var expected = new SyncAction(ChangeType.Deleted, fileReference, null, Guid.NewGuid(), "targetName", SyncActionState.Active,23);
            var actual = m_Instance.Deserialize(m_Instance.Serialize(expected));

            Assert.NotNull(actual);
            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Target, actual.Target);
            Assert.Equal(expected.ToVersion, actual.ToVersion);
            Assert.Equal(expected.FromVersion, actual.FromVersion);
            Assert.Equal(expected.State, actual.State);
            Assert.Equal(expected.SyncPointId, actual.SyncPointId);
        }
        public void SyncAction_Roundtrip_Added()
        {
            var fileReference = new FileReference("/file1", DateTime.Now, 23);
            
            var expected = new SyncAction(ChangeType.Added, null, fileReference, Guid.Parse("A7226A4D-4BE8-4B10-B378-BEF72A29FD24"), "targetName", SyncActionState.Queued, 42);
            var actual = m_Instance.Deserialize(m_Instance.Serialize(expected));

            Assert.NotNull(actual);
            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Target, actual.Target);
            Assert.Equal(expected.FromVersion, actual.FromVersion);
            Assert.Equal(expected.ToVersion, actual.ToVersion);
            Assert.Equal(expected.State, actual.State);
            Assert.Equal(expected.SyncPointId, actual.SyncPointId);
        }
 public void Matches_does_not_match_file_when_only_a_path_is_specified()
 {
     var reference = new FileReference("/dir2/file1");
     Assert.False(reference.Matches(m_File1));
 }
 public void Matches_matches_path_case_invariant()
 {
     var reference = new FileReference("/dIR1/fiLe1");
     Assert.True(reference.Matches(m_File1));
 }
 public void Matches_matches_file_only_by_path()
 {
     var reference = new FileReference("/dir1/file1");
     Assert.True(reference.Matches(m_File1));
 }