using System;
using MileageTraker.Web.Models;
using MileageTraker.Web.ViewModels.User;
using NUnit.Framework;

namespace Web.Tests.ViewModels
{
	[TestFixture]
	public class EditUserViewModelTests
	{
		[Test]
		public void EditUser_FromUser()
		{
			var user = new User();

			var email = user.Email = "bob@dobalina.com";
			var username = user.Username = "bobdobalina";
			var fullName = user.FullName = "Bob Dobalina";
			var userId = user.UserId = Guid.NewGuid();

			var vm = new EditUserViewModel(user);

			Assert.That(vm.Email, Is.EqualTo(email));
			Assert.That(vm.Username, Is.EqualTo(username));
			Assert.That(vm.FullName, Is.EqualTo(fullName));
			Assert.That(vm.UserId, Is.EqualTo(userId));
		}

		[Test]
		public void UpdateUser()
		{
			var vm = new EditUserViewModel();

			var email = vm.Email = "bob@dobalina.com";
			var username = vm.Username = "bobdobalina";
			var fullName = vm.FullName = "Bob Dobalina";
			var userId = vm.UserId = Guid.NewGuid();
			vm.UserId = Guid.NewGuid();

			var user = new User{UserId = userId};
			vm.UpdateUser(user);

			Assert.That(user.Email, Is.EqualTo(email));
			Assert.That(user.Username, Is.EqualTo(username));
			Assert.That(user.FullName, Is.EqualTo(fullName));
			Assert.That(user.UserId, Is.EqualTo(userId));
		}
	}
}
