DeviceService

Learn how to use BELLATRIX iOS DeviceService.

Example

[TestFixture]
public class DeviceServiceTests : IOSTest
{
    [Test]
    public void OrientationSetToLandscape_When_CallRotateWithLandscape()
    {
        App.Device.Rotate(ScreenOrientation.Landscape);

        Assert.AreEqual(ScreenOrientation.Landscape, App.Device.Orientation);

        App.Device.Rotate(ScreenOrientation.Portrait);
    }

    [Test]
    public void CorrectTimeReturned_When_CallDeviceTime()
    {
        DateTimeAssert.AreEqual(DateTime.Now, App.Device.DeviceTime, BA.DateTimeDeltaType.Minutes, 5);
    }

    [Test]
    public void DeviceIsLockedTrue_When_CallLock()
    {
        App.Device.Lock(1);
    }

    [Test]
    public void TestShakeDevice()
    {
        App.Device.ShakeDevice();
    }
}

Explanations

BELLATRIX gives you an interface to most common operations for controlling the device through the DeviceService class.

App.Device.Rotate(ScreenOrientation.Landscape);

Rotates the device horizontally.

Assert.AreEqual(ScreenOrientation.Landscape, App.Device.Orientation);

Gets the current device orientation.

DateTimeAssert.AreEqual(DateTime.Now, App.Device.DeviceTime, BA.DateTimeDeltaType.Minutes, 5);

Asserts current device time.

App.Device.Lock(1);
App.Device.ShakeDevice();

Shakes the device.