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\073\110\112\117\116\046\078\101\120\117\115\067\104\101\099\107\066\111\120")local Y=(L:GetResource("\068\097\116\097\046\069\110\117\109\046\078\101\120\117\115\069\110\117\109\067\111\108\108\101\099\116\105\111\110")).GetBuiltInEnums()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\104\101\099\107\066\111\120","\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\104\101\099\107\066\111\120","\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\104\101\099\107\066\111\120","\078\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(#L:GetChildren(),0,"\067\104\105\108\100\114\101\110 \097\114\101\110\'\116 \104\105\100\100\101\110\046")end)a:RegisterUnitTest("\066\111\120\083\116\097\116\101",function(a)local L=b.new()local T,X=(L:GetWrappedInstance()):FindFirstChild("\073\109\097\103\101\076\097\098\101\108"),(L:GetWrappedInstance()):FindFirstChild("\070\114\097\109\101")L.BoxState=Y.CheckBoxState.Checked a:AssertTrue(T.Visible,"\067\104\101\099\107 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertFalse(X.Visible,"\066\111\120 \105\115 \118\105\115\105\098\108\101\046")a:AssertTrue(L.Selected,"\070\114\097\109\101 \105\115\110\'\116 \115\101\108\101\099\116\101\100\046")L.BoxState=Y.CheckBoxState.Mixed a:AssertFalse(T.Visible,"\067\104\101\099\107 \105\115 \118\105\115\105\098\108\101\046")a:AssertTrue(X.Visible,"\066\111\120 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertFalse(L.Selected,"\070\114\097\109\101 \105\115 \115\101\108\101\099\116\101\100\046")L.BoxState=Y.CheckBoxState.Unchecked a:AssertFalse(T.Visible,"\067\104\101\099\107 \105\115 \118\105\115\105\098\108\101\046")a:AssertFalse(X.Visible,"\066\111\120 \105\115 \118\105\115\105\098\108\101\046")a:AssertFalse(L.Selected,"\070\114\097\109\101 \105\115 \115\101\108\101\099\116\101\100\046")end)a:RegisterUnitTest("\067\111\108\111\114\115",function(a)local L=b.new()local Y,T=(L:GetWrappedInstance()):FindFirstChild("\073\109\097\103\101\076\097\098\101\108"),(L:GetWrappedInstance()):FindFirstChild("\070\114\097\109\101")L.CheckColor3=Color3.new(1,0,0)L.MixedColor3=Color3.new(0,1,0)a:AssertClose(Y.ImageColor3,Color3.new(1,0,0),.0001,"\067\111\108\111\114 \105\115 \110\111\116 \099\108\111\115\101\046")a:AssertClose(T.BackgroundColor3,Color3.new(0,1,0),.0001,"\067\111\108\111\114 \105\115 \110\111\116 \099\108\111\115\101\046")end)a:RegisterUnitTest("\084\111\103\103\108\101",function(a)local L=b.new()L.BoxState=Y.CheckBoxState.Checked L:Toggle()a:AssertTrue(Y.CheckBoxState.Unchecked:Equals(L.BoxState),"\070\105\110\097\108 \115\116\097\116\101 \105\115 \105\110\099\111\114\114\101\099\116\046")L.BoxState=Y.CheckBoxState.Mixed L:Toggle()a:AssertTrue(Y.CheckBoxState.Unchecked:Equals(L.BoxState),"\070\105\110\097\108 \115\116\097\116\101 \105\115 \105\110\099\111\114\114\101\099\116\046")L.BoxState=Y.CheckBoxState.Unchecked L:Toggle()a:AssertTrue(Y.CheckBoxState.Checked:Equals(L.BoxState),"\070\105\110\097\108 \115\116\097\116\101 \105\115 \105\110\099\111\114\114\101\099\116\046")end)return true
--[[
TheNexusAvenger

Tests the NexusCheckBox class.
--]]

local NexusUnitTesting = require("NexusUnitTesting")

local NexusPluginFramework = require(game:GetService("ReplicatedStorage"):WaitForChild("NexusPluginFramework"))
local NexusCheckBox = NexusPluginFramework:GetResource("UI.Input.NexusCheckBox")
local NexusEnums = NexusPluginFramework:GetResource("Data.Enum.NexusEnumCollection").GetBuiltInEnums()



--[[
Test that the constructor works without failing.
--]]
NexusUnitTesting:RegisterUnitTest("Constructor",function(UnitTest)
	local CuT = NexusCheckBox.new()
	UnitTest:AssertEquals(CuT.ClassName,"NexusCheckBox","Class name is incorrect.")
	UnitTest:AssertEquals(CuT.Name,"NexusCheckBox","Name is incorrect.")
	UnitTest:AssertEquals(tostring(CuT),"NexusCheckBox","Name is incorrect.")
	UnitTest:AssertEquals(#CuT:GetChildren(),0,"Children aren't hidden.")
end)

--[[
Tests the BoxState property.
--]]
NexusUnitTesting:RegisterUnitTest("BoxState",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCheckBox.new()
	local ImageLabel,Frame = CuT:GetWrappedInstance():FindFirstChild("ImageLabel"),CuT:GetWrappedInstance():FindFirstChild("Frame")
	
	--Assert the checked box state is correct.
	CuT.BoxState = NexusEnums.CheckBoxState.Checked
	UnitTest:AssertTrue(ImageLabel.Visible,"Check isn't visible.")
	UnitTest:AssertFalse(Frame.Visible,"Box is visible.")
	UnitTest:AssertTrue(CuT.Selected,"Frame isn't selected.")
	
	--Assert the mixed box state is correct.
	CuT.BoxState = NexusEnums.CheckBoxState.Mixed
	UnitTest:AssertFalse(ImageLabel.Visible,"Check is visible.")
	UnitTest:AssertTrue(Frame.Visible,"Box isn't visible.")
	UnitTest:AssertFalse(CuT.Selected,"Frame is selected.")
	
	--Assert the unchecked box state is correct.
	CuT.BoxState = NexusEnums.CheckBoxState.Unchecked
	UnitTest:AssertFalse(ImageLabel.Visible,"Check is visible.")
	UnitTest:AssertFalse(Frame.Visible,"Box is visible.")
	UnitTest:AssertFalse(CuT.Selected,"Frame is selected.")
end)

--[[
Tests the CheckColor3 and MixedColor3 properties.
--]]
NexusUnitTesting:RegisterUnitTest("Colors",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCheckBox.new()
	local ImageLabel,Frame = CuT:GetWrappedInstance():FindFirstChild("ImageLabel"),CuT:GetWrappedInstance():FindFirstChild("Frame")
	
	--Set the colors.
	CuT.CheckColor3 = Color3.new(1,0,0)
	CuT.MixedColor3 = Color3.new(0,1,0)
	
	--Assert the colors are correct.
	UnitTest:AssertClose(ImageLabel.ImageColor3,Color3.new(1,0,0),0.0001,"Color is not close.")
	UnitTest:AssertClose(Frame.BackgroundColor3,Color3.new(0,1,0),0.0001,"Color is not close.")
end)

--[[
Tests the Toggle method.
TODO: Nexus Unit Testing requires NexusEnums twice, leading to the refernces being incorrect.
--]]
NexusUnitTesting:RegisterUnitTest("Toggle",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusCheckBox.new()
	
	--Assert toggling from the checked state is correct.
	CuT.BoxState = NexusEnums.CheckBoxState.Checked
	CuT:Toggle()
	UnitTest:AssertTrue(NexusEnums.CheckBoxState.Unchecked:Equals(CuT.BoxState),"Final state is incorrect.")
	
	--Assert toggling from the mixed state is correct.
	CuT.BoxState = NexusEnums.CheckBoxState.Mixed
	CuT:Toggle()
	UnitTest:AssertTrue(NexusEnums.CheckBoxState.Unchecked:Equals(CuT.BoxState),"Final state is incorrect.")
	
	--Assert toggling from the unchecked state is correct.
	CuT.BoxState = NexusEnums.CheckBoxState.Unchecked
	CuT:Toggle()
	UnitTest:AssertTrue(NexusEnums.CheckBoxState.Checked:Equals(CuT.BoxState),"Final state is incorrect.")
end)



return true