/// <summary> /// Checks that the first record in the list of records is of type <typeparamref name="T"/> and involves the specified state. /// The record is removed after the check. /// </summary> /// <typeparam name="T">Type of the record.</typeparam> /// <param name="state">The state.</param> private void CheckRecord <T>(StateMachine.States state) where T : Record { Record record = this.records.FirstOrDefault(); var x = record.As <T>(); record.Should().NotBeNull(); record.Should().BeAssignableTo <T>(); // ReSharper disable once PossibleNullReferenceException record.State.Should().Be(state, record.Message); this.records.RemoveAt(0); }