Exemplo n.º 1
0
        public async Task If_LargeComplexObjectStored_ThenRetrievedOk()
        {
            var longList = GetLargeListOfStrings();

            // ARRANGE
            // ACT and // ASSERT
            bool startedOk;

            using (var executionContext = CreateTaskExecutionContext())
            {
                startedOk = await executionContext.TryStartAsync();

                Assert.True(startedOk);
                if (startedOk)
                {
                    var myObject = new MyComplexClass()
                    {
                        Id            = 10,
                        Name          = "Rupert",
                        DateOfBirth   = new DateTime(1955, 1, 1),
                        SomeOtherData = new MyOtherComplexClass()
                        {
                            Value = 12.6m,
                            Notes = longList
                        }
                    };

                    var block = (await executionContext.GetObjectBlocksAsync <MyComplexClass>(x => x.WithObject(myObject))).First();
                    Assert.Equal(myObject.Id, block.Block.Object.Id);
                    Assert.Equal(myObject.Name, block.Block.Object.Name);
                    Assert.Equal(myObject.DateOfBirth, block.Block.Object.DateOfBirth);
                    Assert.Equal(myObject.SomeOtherData.Value, block.Block.Object.SomeOtherData.Value);
                    Assert.Equal(myObject.SomeOtherData.Notes.Count, block.Block.Object.SomeOtherData.Notes.Count);

                    for (int i = 0; i < myObject.SomeOtherData.Notes.Count; i++)
                    {
                        Assert.Equal(myObject.SomeOtherData.Notes[i], block.Block.Object.SomeOtherData.Notes[i]);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public async Task If_ComplexObjectStored_ThenRetrievedOk()
        {
            // ARRANGE
            // ACT and // ASSERT
            bool startedOk;

            using (var executionContext = CreateTaskExecutionContext())
            {
                startedOk = await executionContext.TryStartAsync();

                Assert.True(startedOk);
                if (startedOk)
                {
                    var myObject = new MyComplexClass()
                    {
                        Id            = 10,
                        Name          = "Rupert",
                        DateOfBirth   = new DateTime(1955, 1, 1),
                        SomeOtherData = new MyOtherComplexClass()
                        {
                            Value = 12.6m,
                            Notes = new List <string>()
                            {
                                "hello", "goodbye", null
                            }
                        }
                    };

                    var block = (await executionContext.GetObjectBlocksAsync <MyComplexClass>(x => x.WithObject(myObject))).First();
                    Assert.Equal(myObject.Id, block.Block.Object.Id);
                    Assert.Equal(myObject.Name, block.Block.Object.Name);
                    Assert.Equal(myObject.DateOfBirth, block.Block.Object.DateOfBirth);
                    Assert.Equal(myObject.SomeOtherData.Value, block.Block.Object.SomeOtherData.Value);
                    Assert.Equal(myObject.SomeOtherData.Notes[0], block.Block.Object.SomeOtherData.Notes[0]);
                    Assert.Equal(myObject.SomeOtherData.Notes[1], block.Block.Object.SomeOtherData.Notes[1]);
                    Assert.Null(block.Block.Object.SomeOtherData.Notes[2]);
                }
            }
        }