plcsharp/Tests/PLCSharp.Tests/CylinderRegressionTests.cs

29 lines
1009 B
C#

using PLCSharp.VVMs.Cylinders;
using System.Xml.Linq;
namespace PLCSharp.Tests;
public class CylinderRegressionTests
{
[Fact]
public void OutputStatesAndButtonBindingsAreIndependent()
{
var cylinder = new Cylinder { StatusBOut = true };
Assert.True(cylinder.StatusBOut);
Assert.False(cylinder.StatusAOut);
cylinder.StatusAOut = true;
cylinder.StatusBOut = false;
Assert.True(cylinder.StatusAOut);
Assert.False(cylinder.StatusBOut);
using var resource = typeof(CylinderRegressionTests).Assembly.GetManifestResourceStream("Cylinders.xaml");
var view = XDocument.Load(resource!);
foreach (var side in new[] { "A", "B" })
{
var button = view.Descendants(view.Root!.Name.Namespace + "Button")
.Single(b => (string?)b.Attribute("CommandParameter") == side);
Assert.Contains($"SelectedCylinder.Status{side}Out,", (string?)button.Attribute("Background"));
}
}
}