﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SpotifyLocalApi.ResponsesUnitTests
{
    [TestClass()]
    public class StatusTests
    {
        [TestMethod()]
        public void GetHashCodeTest()
        {
            Responses.Internal.Resource res = new Responses.Internal.Resource
            {
                location = new Responses.Internal.Location {og = "location1"},
                name = "resource1",
                uri = "http://res1.com"
            };
            Responses.Status state1 = new Responses.Status
            {
                client_version = "1.0",
                online = false,
                play_enabled = false,
                playing = false,
                playing_position = 5.3,
                repeat = false,
                prev_enabled = false,
                running = false,
                shuffle = false,
                track = new Responses.Internal.Track
                {album_resource = res, artist_resource = res, length = 2, track_resource = res, track_type = "song"}
            };
            Responses.Status state2 = new Responses.Status
            {
                client_version = "1.1",
                online = true,
                play_enabled = false,
                playing = false,
                playing_position = 5.0,
                repeat = false,
                prev_enabled = false,
                running = false,
                shuffle = false,
                track = new Responses.Internal.Track { album_resource = res, artist_resource = res, length = 2, track_resource = res, track_type = "song" }
            };

            Assert.AreEqual(state1.GetHashCode(), state1.GetHashCode());
            Assert.AreNotEqual(state1.GetHashCode(), state2.GetHashCode());
        }

        [TestMethod()]
        public void EqualsTest()
        {
            Responses.Internal.Resource res = new Responses.Internal.Resource
            {
                location = new Responses.Internal.Location { og = "location1" },
                name = "resource1",
                uri = "http://res1.com"
            };
            Responses.Status state1 = new Responses.Status
            {
                client_version = "1.0",
                online = false,
                play_enabled = false,
                playing = false,
                playing_position = 5.3,
                repeat = false,
                prev_enabled = false,
                running = false,
                shuffle = false,
                track = new Responses.Internal.Track { album_resource = res, artist_resource = res, length = 2, track_resource = res, track_type = "song" }
            };
            Responses.Status state2 = new Responses.Status
            {
                client_version = "1.1",
                online = true,
                play_enabled = false,
                playing = false,
                playing_position = 5.0,
                repeat = false,
                prev_enabled = false,
                running = false,
                shuffle = false,
                track = new Responses.Internal.Track { album_resource = res, artist_resource = res, length = 2, track_resource = res, track_type = "song" }
            };

            Assert.AreEqual(state1, state1);
            Assert.AreNotEqual(state1, state2);
        }
    }

    [TestClass()]
    public class TrackTests
    {
        [TestMethod()]
        public void GetHashCodeTest()
        {
            Responses.Internal.Resource res = new Responses.Internal.Resource
            {
                location = new Responses.Internal.Location { og = "location1" },
                name = "resource1",
                uri = "http://res1.com"
            };

            Responses.Internal.Track track1 = new Responses.Internal.Track
            {
                album_resource = res,
                artist_resource = res,
                track_resource = res,
                length = 1,
                track_type = "song1"
            };

            Responses.Internal.Track track2 = new Responses.Internal.Track
            {
                album_resource = res,
                artist_resource = res,
                track_resource = res,
                length = 2,
                track_type = "song2"
            };

            Assert.AreEqual(track1.GetHashCode(), track1.GetHashCode());
            Assert.AreNotEqual(track1.GetHashCode(), track2.GetHashCode());
        }
    }

    [TestClass()]
    public class ResourceTests
    {
        [TestMethod()]
        public void GetHashCodeTest()
        {
            Responses.Internal.Resource res1 = new Responses.Internal.Resource
            {
                location = new Responses.Internal.Location { og = "location1" },
                name = "resource1",
                uri = "http://res1.com"
            };

            Responses.Internal.Resource res2 = new Responses.Internal.Resource
            {
                location = new Responses.Internal.Location { og = "location1" },
                name = "resource2",
                uri = "http://res2.com"
            };
           
            Assert.AreEqual(res1.GetHashCode(), res1.GetHashCode());
            Assert.AreNotEqual(res1.GetHashCode(), res2.GetHashCode());
        }
    }

    [TestClass()]
    public class LocationTests
    {
        [TestMethod()]
        public void GetHashCodeTest()
        {
            Responses.Internal.Location loc1 = new Responses.Internal.Location
            {
                og = "location1"
            };

            Responses.Internal.Location loc2 = new Responses.Internal.Location
            {
                og = "location2"
            };

            Assert.AreEqual(loc1.GetHashCode(), loc1.GetHashCode());
            Assert.AreNotEqual(loc1.GetHashCode(), loc2.GetHashCode());
        }
    }
}
