Ejemplo n.º 1
0
        public async Task SetAsync_Updates_IfPropertyChanges()
        {
            // Arrange
            var mockService = new Mock <IDocumentDBService>(MockBehavior.Strict);

            Item original = new Item
            {
                Id   = "abc123",
                Text = "hello"
            };

            Item updated = new Item
            {
                Id   = "abc123",
                Text = "goodbye"
            };

            mockService
            .Setup(m => m.ReplaceDocumentAsync(_expectedUri, updated))
            .ReturnsAsync(new Document());

            DocumentDBAttribute attribute = new DocumentDBAttribute(DatabaseName, CollectionName)
            {
                Id = Id
            };

            var context = new DocumentDBContext
            {
                Service           = mockService.Object,
                ResolvedAttribute = attribute
            };

            JObject clonedOrig = DocumentDBItemValueBinder <object> .CloneItem(original);

            // Act
            await DocumentDBItemValueBinder <Item> .SetValueInternalAsync(clonedOrig, updated, context);

            // Assert
            mockService.VerifyAll();
        }
Ejemplo n.º 2
0
        public async Task SetAsync_Poco_SkipsUpdate_IfSame()
        {
            // Arrange
            var mockService = new Mock <IDocumentDBService>(MockBehavior.Strict);

            Item original = new Item
            {
                Id   = "abc123",
                Text = "hello"
            };

            Item updated = new Item
            {
                Id   = "abc123",
                Text = "hello"
            };

            DocumentDBAttribute attribute = new DocumentDBAttribute(DatabaseName, CollectionName)
            {
                Id = Id
            };

            var context = new DocumentDBContext
            {
                Service           = mockService.Object,
                ResolvedAttribute = attribute
            };

            JObject clonedOrig = DocumentDBItemValueBinder <object> .CloneItem(original);

            // Act
            await DocumentDBItemValueBinder <Item> .SetValueInternalAsync(clonedOrig, updated, context);

            // Assert

            // nothing on the client should be called
            mockService.VerifyAll();
        }