ResourceTypeControllerTests.cs 1.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using Coscine.Api.Project.Controllers;
using Microsoft.AspNetCore.Mvc;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Coscine.Api.Project.Tests
{
    [TestFixture]
    public class ResourceTypeControllerTests : DefaultControllerTests<ResourceTypeController>
    {
        public ResourceTypeControllerTests() : base(new ResourceTypeController())
        {
        }

        [Test]
        public void TestGettingFields()
        {
            var actionResult = Controller.Fields(Resources[0].Type.Id.ToString());
            Assert.IsTrue(actionResult.GetType() == typeof(OkObjectResult));

            OkObjectResult okObjectResult = (OkObjectResult)actionResult;
            List<string> fields = (List<string>) okObjectResult.Value;
27
            if(fields.Count() == 2)
28
29
            {
                Assert.IsTrue(fields[0] == "BucketName");
30
                Assert.IsTrue(fields[1] == "Size");
31
32
33
34
35
36
37
38
            }
            else
            {
                Assert.Fail("Wrong field count!");
            }
        }
    }
}