Exemplo n.º 1
0
 public void DShape_WhenComparedAgainstDShapeWithSameKey_IsEquivilant()
 {
     int key = 1;
     DShape first = new DShape { key = key };
     DShape second = new DShape { key = key };
     Assert.IsTrue(first.Equivilant(second));
 }
Exemplo n.º 2
0
 public void DShapeWithHtmlAndSqlMembers_WhenScrubbed_RemainsTheSame()
 {
     string malicious = "attribute');DROP TABLE dbo.Users;--";
     DShape shape = new DShape { Json = malicious };
     shape.Scrub();
     Assert.AreEqual(shape.Json, malicious);
 }
Exemplo n.º 3
0
        public IEnumerable<PShape> Shape_Delete(DShape deleting, string username)
        {
            IDataRepository<DImage> images =
                RepositoryFactory.Instance.Construct<DImage>(username);
            IDataRepository<DShape> shapes;
            //Shape is deleted from the shape repository belonging given to user and image.
            if ((shapes = images.FirstOrDefault(x =>
                    x.Image_ID == deleting.Image_ID
                    && x.username == username).shapes as IDataRepository<DShape>)
                != null){
                shapes.Delete(deleting);
            }

            return shapes;
        }
Exemplo n.º 4
0
        public IEnumerable<PShape> Shape_Create(DShape creating, string username)
        {
            IDataRepository<DImage> images =
                RepositoryFactory.Instance.Construct<DImage>(username);
            IDataRepository<DShape> shapes;
            //Finds first repository belonging to given user and image, then creates shape
            if ((shapes = images.FirstOrDefault(x =>
                    x.Image_ID == creating.Image_ID
                    && x.username == username).shapes as IDataRepository<DShape>)
                != null){
                shapes.Create(creating);
            }

            return shapes;
        }
Exemplo n.º 5
0
        public IEnumerable<PShape> Shape_Update(DShape updating, string username)
        {
            IDataRepository<DImage> images =
                RepositoryFactory.Instance.Construct<DImage>(username);
            IDataRepository<DShape> shapes;
            if ((shapes = images.FirstOrDefault(x =>
                    x.Image_ID == updating.Image_ID
                    && x.username == username).shapes as IDataRepository<DShape>)
                != null){
                shapes.Update(updating);
            }

            return shapes;
        }
Exemplo n.º 6
0
 public void DShape_WhenAskedForKey_ReturnsCountryID()
 {
     DShape shape = new DShape { Shape_ID = -1 };
     int key = shape.key;
     Assert.AreEqual(key, shape.Shape_ID);
 }
Exemplo n.º 7
0
 public void Shape_Update(DShape updating)
 {
     drawingService.Shape_Update(updating, User.Identity.Name);
 }
Exemplo n.º 8
0
 public void Shape_Delete(DShape deleting)
 {
     drawingService.Shape_Delete(deleting, User.Identity.Name);
 }
Exemplo n.º 9
0
 public void Shape_Create(DShape creating)
 {
     drawingService.Shape_Create(creating, User.Identity.Name);
 }