﻿using System;
using Xunit;
using DotNetKit.Misc;
using DotNetKit.Misc.Stateful;

namespace DotNetKit.Test
{
    public sealed class StatefulFuncModuleTest
    {
        [Fact]
        public void test_Const()
        {
            var x = new object();
            var f = StatefulFuncModule.Const<int, object>(x);
            Assert.Equal(StatefulResultModule.Create(0, x), f(0));
        }

        [Fact]
        public void test_GetState()
        {
            Assert.Equal(StatefulResultModule.Create(0, 0), StatefulFuncModule.GetState<int>()(0));
        }

        [Fact]
        public void test_SetState()
        {
            var s = new object();
            var result = StatefulFuncModule.SetState(s)(new object());
            Assert.Equal(StatefulResultModule.Create(s, default(Unit)), result);
        }
    }
}
