Ejemplo n.º 1
0
        public void IsReferencedTest_NonReferenced_ReturnFalse()
        {
            var mockObject = new MockDto("TestValue");
            var serverReferenceResolver = new ServerReferenceResolver();

            Assert.IsFalse(serverReferenceResolver.IsReferenced(this, mockObject));
        }
Ejemplo n.º 2
0
        public void IsReferencedTest_Referenced_ReturnTrue()
        {
            var mockObject = new MockDto("TestValue");
            var serverReferenceResolver = new ServerReferenceResolver();

            serverReferenceResolver.GetReference(this, mockObject);
            Assert.IsTrue(serverReferenceResolver.IsReferenced(this, mockObject));
        }
Ejemplo n.º 3
0
        public async Task Serializes_Object(MockDto dto)
        {
            var serializer = new JsonHttpContentSerializer();
            var serialized = serializer.Serialize(dto, encoding: null);
            var str        = await serialized.ReadAsStringAsync();

            var expected = JsonConvert.SerializeObject(dto);

            str.Should().Be(expected);
        }
Ejemplo n.º 4
0
        public async Task Serializes_Object_And_Sets_Content(MockDto dto)
        {
            var builder         = new HttpRequestMessageBuilder();
            var expectedContent = DefaultSerializer.Serialize(dto, DefaultEncoding);
            var actualContent   = builder.SetJsonContent(dto).HttpRequestMessage.Content;

            var expectedString = await expectedContent.ReadAsStringAsync();

            var actualString = await actualContent.ReadAsStringAsync();

            actualString.Should().Be(expectedString);
        }
Ejemplo n.º 5
0
        public void InvokeCtor()
        {
            var dto = new MockDto
                {
                    A = 1,
                    B = 2,
                    C = 3
                };

            @class = InvokeUtil.InvokeCtor<MockClass,MockDto>(dto);

            Assert.That(@class.A,Is.EqualTo(dto.A));
        }
Ejemplo n.º 6
0
        public void InvokeCtor()
        {
            var dto = new MockDto
            {
                A = 1,
                B = 2,
                C = 3
            };

            @class = InvokeUtil.InvokeCtor <MockClass, MockDto>(dto);

            Assert.That(@class.A, Is.EqualTo(dto.A));
        }
Ejemplo n.º 7
0
        public void ResolveReferenceTest_NonReferenced_ReturnDto()
        {
            var           serverReferenceResolver = new ServerReferenceResolver();
            PrivateObject po         = new PrivateObject(serverReferenceResolver);
            var           mockObject = new MockDto("TestValue");
            var           _knownDtos = ((Dictionary <Guid, ServerObjectBase>)po.GetField("_knownDtos"));

            var _knownDtosCount = _knownDtos.Count;

            var stringGuid = serverReferenceResolver.GetReference(this, mockObject);
            var dto        = serverReferenceResolver.ResolveReference(new Guid(stringGuid));

            Assert.IsNotNull(dto);
            Assert.AreEqual(_knownDtosCount + 1, _knownDtos.Count);
        }