﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Werewulf.MediaManager.Common.Model.Base;
using Werewulf.MediaManager.UnitTests.Helper;

namespace Werewulf.MediaManager.UnitTest.CommonTest.Model.Base
{
    [TestClass]
    public class EntityWithIdTest
    {
        [TestMethod]
        public void EntityWithIdUsesPropertyCorrectly()
        {
            // Assign
            var entityWithId = new EntityWithIdImplementation();
            var guid1 = Guid.Parse(Constants.GUID1);
            var guid2 = Guid.Parse(Constants.GUID2);

            // Act
            var result1 = entityWithId.Id;
            entityWithId.Id = guid1;
            var result2 = entityWithId.Id;

            // Assert
            Assert.AreEqual(default(Guid), result1);
            Assert.AreEqual(guid1, result2);
            Assert.ThrowsException<InvalidOperationException>(() => entityWithId.Id = guid2);
        }

        private class EntityWithIdImplementation
            : EntityWithId
        {
        }
    }
}
