Exemple #1
0
        public async Task Controller_Patch()
        {
            var smanager = new SymbolManager(Context, new Config()
            {
                MaxSymsPerPage = 15
            });
            var controller = new ExampleController(User, new ExampleModule(Context), smanager);
            var sym        = await PostTestSymbol(new Symbols.SymbolController(smanager, User));

            await PostTestExample(sym);

            var res = await controller.PatchAsync(1, new ExampleUpdate()
            {
                Description = "test"
            }) as JsonResult;

            var obj = res.Value as Models.Output.Examples.Example;

            Assert.AreEqual(1, obj.SymbolId);
            Assert.AreEqual("test", obj.Description);
            Assert.AreEqual(3, obj.Code.Length);
            User.SetPermissions(new string[] { });
            Assert.ThrowsAsync <Shared.Exceptions.InsuficientPermission>(() => controller.PatchAsync(1, new ExampleUpdate()));
        }