Example #1
0
        public AndConstraint <ByteCollectionAssertions> BeEquivalentTo(IEnumerable <byte> expectedCollection, string because = null, params object[] reasonArgs)
        {
            if (expectedCollection == null)
            {
                throw new ArgumentNullException(nameof(expectedCollection));
            }

            CombinedState equivalency = Compare(Subject, expectedCollection);

            if (equivalency.IsDoneSuccessfully)
            {
                return(new AndConstraint <ByteCollectionAssertions>(this));
            }

            Execute.Assertion
            .BecauseOf(because, reasonArgs)
            .Given(() => equivalency)
            .ForCondition(x => x.Expected.IsDone && !x.Subject.IsDone)
            .FailWith($"Expected byte {{1:x2}} at position {{0:X}} but found no more bytes{Environment.NewLine}Expected: {{2}}{Environment.NewLine}Subject: {{3}}",
                      x => x.Expected.Position,
                      x => x.Expected.Current,
                      x => x.Expected.GetArea(0),
                      x => x.Subject.GetArea(1)
                      )
            .Then
            .ForCondition(x => !x.Expected.IsDone && x.Subject.IsDone)
            .FailWith($"Expected no more bytes at position {{0}} but found {{1:x2}}{Environment.NewLine}Expected: {{2}}{Environment.NewLine}Subject: {{3}}",
                      x => x.Subject.Position,
                      x => x.Subject.Current,
                      x => x.Expected.GetArea(1),
                      x => x.Subject.GetArea(0)
                      )
            ;

            return(new AndConstraint <ByteCollectionAssertions>(this));
        }
Example #2
0
 private static void CombinedStateChanged(IStore store, CombinedState state)
 {
     Console.WriteLine(state.Select(kvp => kvp.Key + ": " + kvp.Value.ToString()));
 }
        /// <inheritdoc />
        protected override void Update()
        {
            CombinedState state = Input.CurrentState;

            IsDown = state.IsKeyOrButtonDown(KeyOrButton);
        }