jeudi 7 février 2019

GET odata /API Testing :

How could I test the following lines of code on c # ?

file.cs

   [EnableQuery]

    public IQueryable<API_FIRM_LINK> GetAPI_FIRM_LINK()
    {
        return db.API_FIRM_LINK;
    }

I want to make sure it retuns API_FIRM_LINK correctly. I have done some unit testing for front end using JS. I am still doing research for backend and using c#

Here is the test file : file.test.cs

            public class API_FIRM_LINKControllerTests
{


    [TestMethod()]
    public void GetAPI_FIRM_LINKTest()
    {  
        //arrange
        int input = 1;
        //act
        string output = API_FIRM_LINK.GetValue(input);
        //assert
        Assert.AreEqual("1", output);
    }

Int input = 1 is just a little test that I created to try it out. How could I implement AAA on this test.

here is part of API_FIRM_LINK cs :

        public partial class API_FIRM_LINK
{
    [Key]

    public System.Guid ApiFirmLinkId { get; set; }
    public System.Guid ApiInstanceId { get; set; }
    public long FirmId { get; set; }
    public string SecretName { get; set; } 
    public bool Resync { get; set; }

Thanks

Aucun commentaire:

Enregistrer un commentaire