Exemple #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)));
        }
Exemple #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);
        }
Exemple #3
0
        public void GetThingByNameReturnsThing()
        {
            // Arrange
            var container = new biz.dfch.CS.Examples.Odata.Client.Utilities.Container(uri);
            var name      = "theThing";

            // Act
            var entity = container.Things.Where(e => e.Name.Equals(name)).First();

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

            // Act
            var entity = container.Things.Where(e => e.Name.Equals(name)).First();

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(name, entity.Name);
        }
Exemple #5
0
        public void GetAllThingsReturnsList()
        {
            // Arrange
            var container = new biz.dfch.CS.Examples.Odata.Client.Utilities.Container(uri);

            // Act
            var entitySet = container.Things.ToList();

            // Assert
            Assert.IsNotNull(entitySet);
            // see https://devaspirin.wordpress.com/2013/04/29/the-assert-isinstanceoftype-headache/
            // for usage on Assert.IsInstanceOfType()
            Assert.IsInstanceOfType(entitySet.GetType(), typeof(List <Thing>).GetType());
            foreach (var entity in entitySet)
            {
                Assert.IsNotNull(entity);
            }
        }
        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 GetAllThingsReturnsList()
        {
            // Arrange
            var container = new biz.dfch.CS.Examples.Odata.Client.Utilities.Container(uri);

            // Act
            var entitySet = container.Things.ToList();

            // Assert
            Assert.IsNotNull(entitySet);
            // see https://devaspirin.wordpress.com/2013/04/29/the-assert-isinstanceoftype-headache/
            // for usage on Assert.IsInstanceOfType()
            Assert.IsInstanceOfType(entitySet.GetType(), typeof(List<Thing>).GetType());
            foreach(var entity in entitySet)
            {
                Assert.IsNotNull(entity);
            }
        }
        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();
        }