local a=require("\078\101\120\117\115\085\110\105\116\084\101\115\116\105\110\103")local L=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\120\117\115\080\108\117\103\105\110\070\114\097\109\101\119\111\114\107"))local b=L:GetResource("\085\073\046\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\046\067\111\110\115\116\114\097\105\110\116\046\078\101\120\117\115\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101\067\111\110\115\116\114\097\105\110\116")a:RegisterUnitTest("\067\111\110\115\116\114\117\099\116\111\114",function(a)local L=b.new()a:AssertEquals(L.ClassName,"\078\101\120\117\115\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101\067\111\110\115\116\114\097\105\110\116","\067\108\097\115\115 \110\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(L.Name,"\078\101\120\117\115\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101\067\111\110\115\116\114\097\105\110\116","\078\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(tostring(L),"\078\101\120\117\115\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101\067\111\110\115\116\114\097\105\110\116","\078\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")end)a:RegisterUnitTest("\067\111\110\116\097\105\110\115\076\105\115\116\070\114\097\109\101",function(a)local Y=b.new()local T,X,R=L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101")Y:AddListFrame(T)Y:AddListFrame(X)a:AssertTrue(Y:ContainsListFrame(T),"\070\114\097\109\101 \100\111\101\115 \110\111\116 \101\120\105\115\116\046")a:AssertTrue(Y:ContainsListFrame(X),"\070\114\097\109\101 \100\111\101\115 \110\111\116 \101\120\105\115\116\046")a:AssertFalse(Y:ContainsListFrame(R),"\070\114\097\109\101 \100\111\101\115 \101\120\105\115\116\046")end)a:RegisterUnitTest("\071\101\116\076\105\115\116\070\114\097\109\101\115",function(a)local Y=b.new()local T,X,R=L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101")Y:AddListFrame(T)Y:AddListFrame(X)Y:AddListFrame(X)local A=Y:GetListFrames()a:AssertEquals(#A,2,"\065\109\111\117\110\116 \111\102 \102\114\097\109\101\115 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(A[1],T,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(A[2],X,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")Y:AddListFrame(R,2)local N=Y:GetListFrames()a:AssertEquals(#N,3,"\065\109\111\117\110\116 \111\102 \102\114\097\109\101\115 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(N[1],T,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(N[2],R,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(N[3],X,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")end)a:RegisterUnitTest("\071\101\116\065\108\108\076\105\115\116\070\114\097\109\101\115",function(a)local Y=b.new()local T,X,R=L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101")Y:AddListFrame(T)Y:AddListFrame(X)T.Expanded=false R.Parent=T:GetCollapsableContainer()local A=Y:GetAllListFrames()a:AssertEquals(#A,3,"\065\109\111\117\110\116 \111\102 \102\114\097\109\101\115 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(A[1],T,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(A[2],R,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(A[3],X,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")local N=Y:GetAllListFrames(true)a:AssertEquals(#N,2,"\065\109\111\117\110\116 \111\102 \102\114\097\109\101\115 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(N[1],T,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(N[2],X,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")end)a:RegisterUnitTest("\083\111\114\116\076\105\115\116\070\114\097\109\101\115",function(a)local Y=b.new()local T,X,R=L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101")T.Name="\070\114\097\109\101\049"X.Name="\070\114\097\109\101\050"R.Name="\070\114\097\109\101\051"Y:AddListFrame(R)Y:AddListFrame(T)Y:AddListFrame(X)Y:SortListFrames(function(a,L)return a.Name<L.Name end)a:AssertEquals(Y:GetListFrames(),{T,X;R},"\079\114\100\101\114 \105\115 \105\110\099\111\114\114\101\099\116\046")end)a:RegisterUnitTest("\082\101\109\111\118\101\076\105\115\116\070\114\097\109\101",function(a)local Y=b.new()local T,X,R=L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101")Y:AddListFrame(T)Y:AddListFrame(X)Y:AddListFrame(R)Y:RemoveListFrame(T)Y:RemoveListFrame(R)Y:RemoveListFrame(R)local A=Y:GetListFrames()a:AssertEquals(#A,1,"\065\109\111\117\110\116 \111\102 \102\114\097\109\101\115 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertSame(A[1],X,"\070\114\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")end)a:RegisterUnitTest("\067\108\101\097\114\076\105\115\116\070\114\097\109\101\115",function(a)local Y=b.new()local T,X,R=L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101"),L.new("\067\111\108\108\097\112\115\097\098\108\101\076\105\115\116\070\114\097\109\101")Y:AddListFrame(T)Y:AddListFrame(X)Y:AddListFrame(R)Y:ClearListFrames()local A=Y:GetListFrames()a:AssertEquals(#A,0,"\065\109\111\117\110\116 \111\102 \102\114\097\109\101\115 \105\115 \105\110\099\111\114\114\101\099\116\046")end)return true
--[[
TheNexusAvenger

Tests the NexusCollapsableListFrameConstraint class.
--]]

local NexusUnitTesting = require("NexusUnitTesting")

local NexusPluginFramework = require(game:GetService("ReplicatedStorage"):WaitForChild("NexusPluginFramework"))
local NexusCollapsableListFrameConstraint = NexusPluginFramework:GetResource("UI.CollapsableList.Constraint.NexusCollapsableListFrameConstraint")



--[[
Test that the constructor works without failing.
--]]
NexusUnitTesting:RegisterUnitTest("Constructor",function(UnitTest)
	local CuT = NexusCollapsableListFrameConstraint.new()
	UnitTest:AssertEquals(CuT.ClassName,"NexusCollapsableListFrameConstraint","Class name is incorrect.")
	UnitTest:AssertEquals(CuT.Name,"NexusCollapsableListFrameConstraint","Name is incorrect.")
	UnitTest:AssertEquals(tostring(CuT),"NexusCollapsableListFrameConstraint","Name is incorrect.")
end)

--[[
Tests the ContainsListFrame method.
--]]
NexusUnitTesting:RegisterUnitTest("ContainsListFrame",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCollapsableListFrameConstraint.new()
	
	--Create 3 list frames and add 2 of them.
	local Frame1,Frame2,Frame3 = NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame")
	CuT:AddListFrame(Frame1)
	CuT:AddListFrame(Frame2)
	
	--Assert the correct frames are in the constraint.
	UnitTest:AssertTrue(CuT:ContainsListFrame(Frame1),"Frame does not exist.")
	UnitTest:AssertTrue(CuT:ContainsListFrame(Frame2),"Frame does not exist.")
	UnitTest:AssertFalse(CuT:ContainsListFrame(Frame3),"Frame does exist.")
end)

--[[
Tests the GetListFrames method.
--]]
NexusUnitTesting:RegisterUnitTest("GetListFrames",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCollapsableListFrameConstraint.new()
	
	--Create 3 list frames and add 2 of them.
	local Frame1,Frame2,Frame3 =  NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame")
	CuT:AddListFrame(Frame1)
	CuT:AddListFrame(Frame2)
	CuT:AddListFrame(Frame2)
	
	--Assert the correct frames are in the constraint.
	local Frames = CuT:GetListFrames()
	UnitTest:AssertEquals(#Frames,2,"Amount of frames is incorrect.")
	UnitTest:AssertSame(Frames[1],Frame1,"Frame is incorrect.")
	UnitTest:AssertSame(Frames[2],Frame2,"Frame is incorrect.")
	
	--Assert adding a third frame at the 2nd index.
	CuT:AddListFrame(Frame3,2)
	local Frames = CuT:GetListFrames()
	UnitTest:AssertEquals(#Frames,3,"Amount of frames is incorrect.")
	UnitTest:AssertSame(Frames[1],Frame1,"Frame is incorrect.")
	UnitTest:AssertSame(Frames[2],Frame3,"Frame is incorrect.")
	UnitTest:AssertSame(Frames[3],Frame2,"Frame is incorrect.")
end)

--[[
Tests the GetAllListFrames method.
--]]
NexusUnitTesting:RegisterUnitTest("GetAllListFrames",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCollapsableListFrameConstraint.new()
	
	--Create 3 list frames and add them.
	local Frame1,Frame2,Frame3 = NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame")
	CuT:AddListFrame(Frame1)
	CuT:AddListFrame(Frame2)
	Frame1.Expanded = false
	Frame3.Parent = Frame1:GetCollapsableContainer()
	
	--Assert the frames are correct.
	local Frames = CuT:GetAllListFrames()
	UnitTest:AssertEquals(#Frames,3,"Amount of frames is incorrect.")
	UnitTest:AssertSame(Frames[1],Frame1,"Frame is incorrect.")
	UnitTest:AssertSame(Frames[2],Frame3,"Frame is incorrect.")
	UnitTest:AssertSame(Frames[3],Frame2,"Frame is incorrect.")
	
	--Assert the frames are correct.
	local Frames = CuT:GetAllListFrames(true)
	UnitTest:AssertEquals(#Frames,2,"Amount of frames is incorrect.")
	UnitTest:AssertSame(Frames[1],Frame1,"Frame is incorrect.")
	UnitTest:AssertSame(Frames[2],Frame2,"Frame is incorrect.")
end)

--[[
Tests the SortListFrames method.
--]]
NexusUnitTesting:RegisterUnitTest("SortListFrames",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCollapsableListFrameConstraint.new()
	
	--Create 3 list frames and add them.
	local Frame1,Frame2,Frame3 = NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame")
	Frame1.Name = "Frame1"
	Frame2.Name = "Frame2"
	Frame3.Name = "Frame3"
	CuT:AddListFrame(Frame3)
	CuT:AddListFrame(Frame1)
	CuT:AddListFrame(Frame2)
	
	--Sort the list frames.
	CuT:SortListFrames(function(a,b)
		return a.Name < b.Name
	end)
	
	--Assert the order is correct.
	UnitTest:AssertEquals(CuT:GetListFrames(),{Frame1,Frame2,Frame3},"Order is incorrect.")
end)

--[[
Tests the RemoveListFrame method.
--]]
NexusUnitTesting:RegisterUnitTest("RemoveListFrame",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCollapsableListFrameConstraint.new()
	
	--Create 3 list frames and add them.
	local Frame1,Frame2,Frame3 = NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame")
	CuT:AddListFrame(Frame1)
	CuT:AddListFrame(Frame2)
	CuT:AddListFrame(Frame3)
	
	--Assert the frames are removed.
	CuT:RemoveListFrame(Frame1)
	CuT:RemoveListFrame(Frame3)
	CuT:RemoveListFrame(Frame3)
	
	local Frames = CuT:GetListFrames()
	UnitTest:AssertEquals(#Frames,1,"Amount of frames is incorrect.")
	UnitTest:AssertSame(Frames[1],Frame2,"Frame is incorrect.")
end)

--[[
Tests the ClearListFrames method.
--]]
NexusUnitTesting:RegisterUnitTest("ClearListFrames",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCollapsableListFrameConstraint.new()
	
	--Create 3 list frames and add them.
	local Frame1,Frame2,Frame3 = NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame"),NexusPluginFramework.new("CollapsableListFrame")
	CuT:AddListFrame(Frame1)
	CuT:AddListFrame(Frame2)
	CuT:AddListFrame(Frame3)
	
	--Assert the frames are removed.
	CuT:ClearListFrames()
	local Frames = CuT:GetListFrames()
	UnitTest:AssertEquals(#Frames,0,"Amount of frames is incorrect.")
end)



return true