Exemplo n.º 1
0
    public void ExecuteAfter_Update(ActionContext e)
    {
        if (!(e.Args is ActionDataSource.UpdateEventArgs) || !CheckDataSource(e) || RelationEditor == null)
        {
            return;
        }
        var    updateArgs = (ActionDataSource.UpdateEventArgs)e.Args;
        object contextEntityId;

        if (updateArgs.Keys.Contains(EntityIdField))
        {
            contextEntityId = updateArgs.Keys[EntityIdField];
        }
        else
        {
            contextEntityId = updateArgs.Values[EntityIdField];
        }
        // plugin can be used inside list. Lets check with saved id
        if (EntityId != null && EntityId != DBNull.Value && !AssertHelper.AreEquals(EntityId, contextEntityId))
        {
            return;
        }
        EntityId = contextEntityId;
        Save();
    }
Exemplo n.º 2
0
        public void ChunkBinarySerializationTest()
        {
            // arrange
            IFormatter formatter = new BinaryFormatter();
            var        chunk     = new Chunk(1024, 1024 + _testData.Length)
            {
                Position = 1,
                Timeout  = 1000,
                MaxTryAgainOnFailover = 3000,
                Storage = Storage
            };

            chunk.Storage.WriteAsync(_testData, 0, _testData.Length).Wait();
            using var serializedChunk = new MemoryStream();

            // act
            formatter.Serialize(serializedChunk, chunk);
            serializedChunk.Flush();
            serializedChunk.Seek(0, SeekOrigin.Begin);
            var deserializedChunk = formatter.Deserialize(serializedChunk) as Chunk;

            // assert
            AssertHelper.AreEquals(chunk, deserializedChunk);

            chunk.Clear();
        }
Exemplo n.º 3
0
        public void ChunkSerializationTest()
        {
            // arrange
            var settings = new JsonSerializerSettings();

            settings.Converters.Add(new StorageConverter());
            var chunk = new Chunk(1024, 1024 + _testData.Length)
            {
                Position = 1,
                Timeout  = 1000,
                MaxTryAgainOnFailover = 3000,
                Storage = Storage
            };

            chunk.Storage.WriteAsync(_testData, 0, _testData.Length).Wait();

            // act
            var serializedChunk   = JsonConvert.SerializeObject(chunk);
            var deserializedChunk = JsonConvert.DeserializeObject <Chunk>(serializedChunk, settings);

            // assert
            AssertHelper.AreEquals(chunk, deserializedChunk);

            chunk.Clear();
        }
Exemplo n.º 4
0
 protected IEnumerable GetLevelData(object parent)
 {
     foreach (var item in Data)
     {
         if (String.IsNullOrEmpty(ParentFieldName) || AssertHelper.AreEquals(DataBinder.Eval(item, ParentFieldName), parent))
         {
             yield return(item);
         }
     }
 }
Exemplo n.º 5
0
        private void PackagesAreEqual(DownloadPackage source, DownloadPackage destination)
        {
            Assert.IsNotNull(source);
            Assert.IsNotNull(destination);
            Assert.IsNotNull(source.Chunks);
            Assert.IsNotNull(destination.Chunks);
            Assert.AreEqual(source.FileName, destination.FileName);
            Assert.AreEqual(source.ReceivedBytesSize, destination.ReceivedBytesSize);
            Assert.AreEqual(source.Address, destination.Address);
            Assert.AreEqual(source.TotalFileSize, destination.TotalFileSize);
            Assert.AreEqual(source.IsSaving, destination.IsSaving);
            Assert.AreEqual(source.IsSaveComplete, destination.IsSaveComplete);
            Assert.AreEqual(source.SaveProgress, destination.SaveProgress);
            Assert.AreEqual(source.Chunks?.Length, destination.Chunks?.Length);

            for (int i = 0; i < source.Chunks.Length; i++)
            {
                AssertHelper.AreEquals(source.Chunks[i], destination.Chunks[i]);
            }
        }
Exemplo n.º 6
0
 public bool AreEquals(object o1, object o2)
 {
     return(AssertHelper.AreEquals(o1, o2));
 }