Esempio n. 1
0
        public void CreateThingReturnsHttp201()
        {
            // Arrange
            var container = new biz.dfch.CS.Examples.Odata.Client.Utilities.Container(uri);
            var name      = "theThing";
            var entity    = new Thing();

            entity.Name        = name;
            entity.Description = new Decimal(1.0);

            // Act
            container.AddToThings(entity);
            container.UpdateObject(entity);
            var serviceResponse = container.SaveChanges();

            // Assert
            Assert.AreEqual(1, serviceResponse.Count());
            var r = serviceResponse.First();

            Assert.IsNotNull(r);
            Assert.AreEqual(201, r.StatusCode);
            Assert.IsNull(r.Error);

            Assert.IsNotNull(container.Things.Select(i => i.ID.Equals(entity.ID)));
        }
Esempio n. 2
0
        public void UpdateThingReturnsHttp204()
        {
            // Arrange
            var container = new biz.dfch.CS.Examples.Odata.Client.Utilities.Container(uri);
            var name      = "theThing";
            var nameNew   = "theOtherThing";
            var entity    = container.Things.Where(e => e.Name.Equals(name)).First();

            // Act
            entity.Name = nameNew;
            container.UpdateObject(entity);
            var serviceResponse = container.SaveChanges();

            // Assert
            Assert.AreEqual(1, serviceResponse.Count());
            var r = serviceResponse.First();

            Assert.IsNotNull(r);
            Assert.AreEqual(204, r.StatusCode);
            Assert.IsNull(r.Error);

            var entityNew = container.Things.Where(i => i.Name.Equals(nameNew)).Single();

            Assert.IsNotNull(entityNew);
            Assert.AreEqual(nameNew, entityNew.Name);
        }
        public void CreateThingReturnsHttp201()
        {
            // Arrange
            var container = new biz.dfch.CS.Examples.Odata.Client.Utilities.Container(uri);
            var name = "theThing";
            var entity = new Thing();
            entity.Name = name;
            entity.Description = new Decimal(1.0);

            // Act
            container.AddToThings(entity);
            container.UpdateObject(entity);
            var serviceResponse = container.SaveChanges();

            // Assert
            Assert.AreEqual(1, serviceResponse.Count());
            var r = serviceResponse.First();
            Assert.IsNotNull(r);
            Assert.AreEqual(201, r.StatusCode);
            Assert.IsNull(r.Error);

            Assert.IsNotNull(container.Things.Select(i => i.ID.Equals(entity.ID)));
        }
        public void DeleteThingReturnsHttp204()
        {
            // Arrange
            var container = new biz.dfch.CS.Examples.Odata.Client.Utilities.Container(uri);
            var name = "theOtherThing";
            var entity = container.Things.Where(e => e.Name.Equals(name)).First();

            // Act
            container.DeleteObject(entity);
            var serviceResponse = container.SaveChanges();

            // Assert
            Assert.AreEqual(1, serviceResponse.Count());
            var r = serviceResponse.First();
            Assert.IsNotNull(r);
            Assert.AreEqual(204, r.StatusCode);
            Assert.IsNull(r.Error);

            container.Things.Where(i => i.ID.Equals(entity.ID)).Single();
        }