Пример #1
0
 public void Setup()
 {
     if (_item == null)
         _item = new Item {Text = "Just some random text"};
     if (_client == null)
         _client = new MobileServiceClient(string.Empty /* Your endpoint */, string.Empty /* Your Api key */);
 }
Пример #2
0
        public void Insert_Some_Random_Item_Into_Zumo()
        {
            // Arrange 

            // Act
            _item = _client.GetTable<Item>().Insert(_item);

            // Assert

        }
Пример #3
0
        public void Delete_Some_Random_Item_Into_Zumo()
        {
            // Arrange
            var item = new Item { Id = 1, Text = "Random Text" };
            Mock.Setup(m => m.Delete(item)).Verifiable();

            // Act
            Mock.Object.Delete(item.Id);

            // Assert
            Mock.Verify(m => m.Delete(item.Id));
        }
Пример #4
0
        public void Get_Some_Random_Item_From_Zumo()
        {
            // Arrange
            var item = new Item { Id = 1, Text = "Random Text" };
            Mock.Setup(m => m.Get(item.Id)).Returns(new Item { Id = 1, Text = "Random Text" });

            // Act
            item = Mock.Object.Get(item.Id);

            // Assert
            Assert.IsNotNull(item);
        }
Пример #5
0
        public void Filter_Brings_Back_Only_Item_With_Text_Filtered_On()
        {
            // Arrange
            _item = _client.GetTable<Item>().Insert(_item);
            var expected = _item;
            // Act
            var actual = _client.QueryTable<Item>().Filter(string.Format("text eq '{0}'", _item.Text)).First();

            // Assert
            Assert.AreEqual(actual, expected);
            _client.GetTable<Item>().Delete(_item.Id);
        }
Пример #6
0
        public void Delete_Some_Random_Item_Into_Zumo()
        {
            // Arrange
            if (_item.Id == null)
            {
                _item.Text = "Just something else";
                _item = _client.GetTable<Item>().Insert(_item);
            }
            // Act
            _client.GetTable<Item>().Delete(_item.Id);

            // Assert
        }
Пример #7
0
        public void Update_Some_Random_Item_Into_Zumo()
        {
            // Arrange
            _item.Text = "Just something else";
            _item = _client.GetTable<Item>().Insert(_item);
            // This just doesn't seem right but you need to set the Id to null
            // or ignore it when serializing to Json
            var id = _item.Id;
            // Act
            var actual = _client.GetTable<Item>().Update(id, _item);

            // Assert
            Assert.AreEqual(_item, actual);
            // Reset the Id back so we can delete
            _item.Id = id;
        }
Пример #8
0
        public void Update_Some_Random_Item_Into_Zumo()
        {
            // Arrange
            var item = new Item { Id = 1, Text = "Random Text" };
            // This just doesn't seem right but you need to set the Id to null
            // or ignore it when serializing to Json
            var id = item.Id;
            item.Id = null;
            Mock.Setup(m => m.Update(id, item)).Returns(new Item { Id = 1, Text = "Random Text" });
            // Act
            var actual = Mock.Object.Update(id,item);

            // Reset the Id back so we can delete
            item.Id = id;

            // Assert
            Assert.AreEqual(item.Id, actual.Id);
            Assert.AreEqual(item.Text, actual.Text);
        }