Exemplo n.º 1
0
        public void Get_By_Id_Should_Return_Ressource_Server_For_Existing_Id()
        {
            FakeDataBase.Instance.Scopes.Add(new Scope()
            {
                Id                = 654,
                NiceWording       = "test 1",
                RessourceServerId = _validRessourceServer.Id,
                Wording           = "test_1"
            });

            FakeDataBase.Instance.Scopes.Add(new Scope()
            {
                Id                = 653,
                NiceWording       = "test 2",
                RessourceServerId = _validRessourceServer.Id,
                Wording           = "test_2"
            });

            var result = _service.GetById(_validRessourceServer.Id);

            Assert.IsNotNull(result);
            Assert.AreEqual(_validRessourceServer.Id, result.Id);
            Assert.AreEqual(_validRessourceServer.Login, result.Login);
            Assert.AreEqual(_validRessourceServer.Name, result.Name);
            Assert.AreEqual(_validRessourceServer.Description, result.Description);
            Assert.AreEqual(FakeDataBase.Instance.Scopes.Where(s => s.RessourceServerId.Equals(_validRessourceServer.Id)).Count(), result.Scopes.Count());
            foreach (var s in FakeDataBase.Instance.Scopes.Where(s => s.RessourceServerId.Equals(_validRessourceServer.Id)).Select(s => s.NiceWording))
            {
                Assert.IsTrue(result.Scopes.Select(sc => sc.NiceWording).Contains(s));
            }
        }
Exemplo n.º 2
0
 public IActionResult Get(int id)
 {
     return(Ok(_service.GetById(id)));
 }