using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xunit;
using Xunit.Abstractions;
using Xunit.Extensions;
using Xunit.Sdk;

using TupleStudy;

namespace TupleStudyTest
{
    public class TupleStudyTest
    {
        private TupleStudy.TupleStudy tupleStudy;

        public TupleStudyTest()
        {
            tupleStudy = new TupleStudy.TupleStudy();
        }

        [Fact]
        public void GetTuple_Constructor_One_Test()
        {
            var tuple = tupleStudy.GetTuple_Constructor_One();
            Assert.Equal(1, tuple.Item1);
        }

        [Fact]
        public void GetTuple_Constructor_One_Test2()
        {
            var tuple = tupleStudy.GetTuple_Constructor_One<int>(5);
            Assert.Equal(5, tuple.Item1);

            var tuple2 = tupleStudy.GetTuple_Constructor_One<string>("wanggaofeng");
            Assert.Equal("wanggaofeng", tuple2.Item1);

            var student = new Student() { Id = 1, Name = "wanggaofeng", Age = 28 };

            var studentTuple = tupleStudy.GetTuple_Constructor_One <Student>(student);
            Assert.Equal(student, studentTuple.Item1);
        }

        [Fact]
        public void GetTuple_StaticMethod_Tow_Test()
        {
            var tuple = tupleStudy.GetTuple_StaticMethod_Tow<int,string>(5,"wanggaofeng");
            Assert.Equal(5, tuple.Item1);
            Assert.Equal("wanggaofeng", tuple.Item2);

            var student = new Student() { Id = 1, Name = "wanggaofeng", Age = 28 };
            Assert.Equal(1, student.Id);
            Assert.Equal("wanggaofeng", student.Name);
            Assert.Equal(28, student.Age);

            var studentTuple = tupleStudy.GetTuple_StaticMethod_Tow<string,Student>("静态方法",student);
            Assert.Equal("静态方法", studentTuple.Item1);
            Assert.Equal(student, studentTuple.Item2);
        }

        [Fact]
        public void GetTuple_Constructor_Nest_Test()
        {
            var tuple = tupleStudy.GetTuple_Constructor_Nest();

            Assert.Equal(1, tuple.Item1);
            Assert.Equal(2, tuple.Item2);
            Assert.Equal(3, tuple.Item3);
            Assert.Equal(4, tuple.Item4);
            Assert.Equal(5, tuple.Item5);
            Assert.Equal(6, tuple.Item6);
            Assert.Equal(7, tuple.Item7);

            Assert.Equal(8, tuple.Rest.Item1);
            Assert.Equal("嵌套Tuple", tuple.Rest.Item2);
        }

        [Fact]
        public void GetStudentTuple_Test()
        {
            var tuple = tupleStudy.GetStudentTuple(2,"王高峰",30);
            Assert.Equal(2, tuple.Item1);
            Assert.Equal("王高峰", tuple.Item2);
            Assert.True(30==tuple.Item3);
        }

        [Fact]
        public void SashEgg_Test()
        {
            var tuple1 = new Tuple<string,int, string, int, decimal>("错误的参数",1, "白色金蛋", 2018001, new decimal(25.50));
            var reslul1 = tupleStudy.SmashEgg(tuple1);
            Assert.False(reslul1);

            var tuple2 = new Tuple<int,string,int,decimal>(1, "白色金蛋", 2018001, new decimal(25.50));
            var reslul2 = tupleStudy.SmashEgg(tuple2);
            Assert.False(reslul2);

            var tuple3 = new Tuple<int, string, int, decimal>(2, "白色金蛋", 2018001, new decimal(25.50));
            var reslul3 = tupleStudy.SmashEgg(tuple3);
            Assert.True(reslul3);
        }
    }
}