Example #1
0
        public async Task Controller_POST()
        {
            var controller = new TypeController(Manager, User);

            var mdl = await controller.PostAsync(new TypeCreate()
            {
                Name = "test"
            }) as JsonResult;

            var obj = mdl.Value as Models.Output.Symbols.Type;

            Assert.ThrowsAsync <Shared.Exceptions.ResourceAlreadyExists>(() => controller.PostAsync(new TypeCreate()
            {
                Name = "test"
            }));

            Assert.AreEqual(1, obj.Id);
            Assert.AreEqual("test", obj.Name);

            User.SetPermissions(new string[] { });
            Assert.ThrowsAsync <Shared.Exceptions.InsuficientPermission>(() => controller.PostAsync(new TypeCreate()));
        }
Example #2
0
        public async Task Controller_GET()
        {
            var controller = new TypeController(Manager, User);

            var mdl = await controller.PostAsync(new TypeCreate()
            {
                Name = "test"
            }) as JsonResult;

            var obj = mdl.Value as Models.Output.Symbols.Type;

            Assert.AreEqual(1, obj.Id);
            Assert.AreEqual("test", obj.Name);

            var res   = controller.AllTypes() as JsonResult;
            var types = res.Value as IEnumerable <Models.Output.Symbols.Type>;

            Assert.AreEqual(1, types.Count());
            Assert.AreEqual("test", types.First().Name);
        }
Example #3
0
        public async Task Controller_DELETE()
        {
            var controller = new TypeController(Manager, User);

            var mdl = await controller.PostAsync(new TypeCreate()
            {
                Name = "test"
            }) as JsonResult;

            var obj = mdl.Value as Models.Output.Symbols.Type;

            Assert.AreEqual(1, obj.Id);
            Assert.AreEqual("test", obj.Name);
            Assert.AreEqual(1, Context.SymbolTypes.Count());

            await controller.DeleteAsync(1);

            Assert.AreEqual(0, Context.SymbolTypes.Count());

            User.SetPermissions(new string[] { });
            Assert.ThrowsAsync <Shared.Exceptions.InsuficientPermission>(() => controller.DeleteAsync(1));
        }