Exemplo n.º 1
0
 private Device CreateTestEntry(out string entityId, out string name, out string areaId, out DisabledByEnum disabledBy)
 {
     entityId   = MockHelpers.GetRandomEntityId(KnownDomains.Esphome);
     name       = MockHelpers.GetRandomTestName();
     areaId     = MockHelpers.GetRandomTestName();
     disabledBy = DisabledByEnum.Integration;
     return(Device.CreateUnmodified(entityId, name, areaId, disabledBy));
 }
 private EntityRegistryEntry CreateTestEntry(out string entityId, out string name, out string icon, out DisabledByEnum disabledBy)
 {
     entityId   = MockHelpers.GetRandomEntityId(KnownDomains.InputBoolean);
     name       = MockHelpers.GetRandomTestName();
     icon       = "mdi:camera";
     disabledBy = DisabledByEnum.Integration;
     return(EntityRegistryEntry.CreateUnmodified(entityId, name, icon, disabledBy));
 }
Exemplo n.º 3
0
 private InputBoolean CreateTestEntry(out string entityId, out string name, out string icon, out bool initial)
 {
     entityId = MockHelpers.GetRandomEntityId(KnownDomains.InputBoolean);
     name     = MockHelpers.GetRandomTestName();
     icon     = "mdi:fan";
     initial  = true;
     return(InputBoolean.CreateUnmodified(entityId, name, icon, initial));
 }
Exemplo n.º 4
0
 private Person CreateTestEntry(out string entityId, out string name, out User user, out string picture, out IEnumerable <string> deviceTrackers)
 {
     entityId       = MockHelpers.GetRandomEntityId(KnownDomains.Person);
     name           = MockHelpers.GetRandomTestName();
     user           = User.CreateUnmodified(MockHelpers.GetRandomTestName(), name, false);
     picture        = "/test/Picture.png";
     deviceTrackers = new[] { MockHelpers.GetRandomEntityId(KnownDomains.DeviceTracker), MockHelpers.GetRandomEntityId(KnownDomains.DeviceTracker) };
     return(Person.CreateUnmodified(entityId, name, user.Id, picture, deviceTrackers));
 }
Exemplo n.º 5
0
 private Zone CreateTestEntry(out string name, out string icon, out float longitude, out float latitude, out float radius, out bool isPassive)
 {
     name      = MockHelpers.GetRandomTestName();
     icon      = "mdi:zone";
     longitude = 20;
     latitude  = 30;
     radius    = 5;
     isPassive = false;
     return(Zone.CreateUnmodified("testId", name, longitude, latitude, radius, icon, isPassive));
 }
Exemplo n.º 6
0
        public void SetNewNameMakesHasPendingChangesTrue()
        {
            var testEntry = this.CreateTestEntry(out var initialName);

            testEntry.Name = MockHelpers.GetRandomTestName();
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.Name = initialName;
            Assert.False(testEntry.HasPendingChanges);
        }
Exemplo n.º 7
0
        public void SetNewPictureMakesHasPendingChangesTrue()
        {
            var testEntry = this.CreateTestEntry(out _, out var picture);

            testEntry.Picture = $"/test/{MockHelpers.GetRandomTestName()}.png";
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.Picture = picture;
            Assert.False(testEntry.HasPendingChanges);
        }
Exemplo n.º 8
0
        public void SetNewIconMakesHasPendingChangesTrue()
        {
            var testEntry = TestRegistryEntry.CreateUnmodified(out _, out var initialIcon);

            testEntry.Icon = MockHelpers.GetRandomTestName();
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.Icon = initialIcon;
            Assert.False(testEntry.HasPendingChanges);
        }
Exemplo n.º 9
0
        public void SetNewIconMakesHasPendingChangesTrue()
        {
            var testEntry = this.CreateTestEntry(out _, out _, out var initialIcon, out _);

            testEntry.Icon = MockHelpers.GetRandomTestName();
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.Icon = initialIcon;
            Assert.False(testEntry.HasPendingChanges);
        }
Exemplo n.º 10
0
        public void DiscardPendingChanges()
        {
            var testEntry = this.CreateTestEntry(out var initialName, out var initialPicture);

            testEntry.Name    = MockHelpers.GetRandomTestName();
            testEntry.Picture = $"/test/{MockHelpers.GetRandomTestName()}.png";
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.DiscardPendingChanges();
            Assert.False(testEntry.HasPendingChanges);
            Assert.AreEqual(initialName, testEntry.Name);
            Assert.AreEqual(initialPicture, testEntry.Picture);
        }
Exemplo n.º 11
0
        public void DiscardPendingChanges()
        {
            var testEntry = TestRegistryEntry.CreateUnmodified(out var initialName, out var initialIcon);

            testEntry.Name = MockHelpers.GetRandomTestName();
            testEntry.Icon = MockHelpers.GetRandomTestName();
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.DiscardPendingChanges();
            Assert.False(testEntry.HasPendingChanges);
            Assert.AreEqual(initialName, testEntry.Name);
            Assert.AreEqual(initialIcon, testEntry.Icon);
        }
Exemplo n.º 12
0
        public void NameIsNameByUserIfDefined()
        {
            var testEntry = this.CreateTestEntry(out _, out _, out _, out _);

            Assert.AreEqual(testEntry.OriginalName, testEntry.Name);

            var testName = MockHelpers.GetRandomTestName();

            testEntry.Name = testName;
            Assert.AreEqual(testName, testEntry.Name);

            testEntry.Name = null;
            Assert.AreEqual(testEntry.OriginalName, testEntry.Name);
        }
Exemplo n.º 13
0
        public void DiscardPendingChanges()
        {
            var testEntry = this.CreateTestEntry(out _, out var initialName, out var initialIcon, out var initial);

            testEntry.Name    = MockHelpers.GetRandomTestName();
            testEntry.Icon    = MockHelpers.GetRandomTestName();
            testEntry.Initial = !initial;
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.DiscardPendingChanges();
            Assert.False(testEntry.HasPendingChanges);
            Assert.AreEqual(initialName, testEntry.Name);
            Assert.AreEqual(initialIcon, testEntry.Icon);
            Assert.AreEqual(initial, testEntry.Initial);
        }
Exemplo n.º 14
0
        public void DiscardPendingChanges()
        {
            var testEntry = this.CreateTestEntry(out _, out var initialName, out var initialAreaId, out var initialDisabledBy);

            testEntry.Name   = MockHelpers.GetRandomTestName();
            testEntry.AreaId = MockHelpers.GetRandomTestName();
            //testEntry.DisabledBy = DisabledByEnum.User;
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.DiscardPendingChanges();
            Assert.False(testEntry.HasPendingChanges);
            Assert.AreEqual(initialName, testEntry.Name);
            Assert.AreEqual(initialAreaId, testEntry.AreaId);
            Assert.AreEqual(initialDisabledBy, testEntry.DisabledBy);
        }
Exemplo n.º 15
0
        public void DiscardPendingChanges()
        {
            var testEntry = this.CreateTestEntry(out _, out var initialName, out var initialUser, out var initialPicture, out var initialDeviceTrackers);

            testEntry.Name = MockHelpers.GetRandomTestName();
            testEntry.ChangeUser(this.testUser);
            testEntry.Picture = $"/test/{MockHelpers.GetRandomTestName()}.png";
            testEntry.DeviceTrackers.Add(MockHelpers.GetRandomEntityId(KnownDomains.DeviceTracker));
            Assert.IsTrue(testEntry.HasPendingChanges);

            testEntry.DiscardPendingChanges();
            Assert.False(testEntry.HasPendingChanges);
            Assert.AreEqual(initialName, testEntry.Name);
            Assert.AreEqual(initialUser.Id, testEntry.UserId);
            Assert.AreEqual(initialPicture, testEntry.Picture);
            Assert.AreEqual(initialDeviceTrackers, testEntry.DeviceTrackers);
        }
Exemplo n.º 16
0
        public void NewPersonHasPendingChanges()
        {
            var testEntry = new Person(MockHelpers.GetRandomTestName(), this.testUser);

            Assert.IsTrue(testEntry.HasPendingChanges);
        }
Exemplo n.º 17
0
        public void NewInputBooleanIsUntracked()
        {
            var testEntry = new InputBoolean(MockHelpers.GetRandomTestName());

            Assert.False(testEntry.IsTracked);
        }
Exemplo n.º 18
0
        public void NewInputBooleanHasPendingChanges()
        {
            var testEntry = new InputBoolean(MockHelpers.GetRandomTestName());

            Assert.IsTrue(testEntry.HasPendingChanges);
        }
Exemplo n.º 19
0
 public TestRegistryEntry()
     : this(MockHelpers.GetRandomTestName(), "mdi:camera")
 {
 }
Exemplo n.º 20
0
        public void NewPersonIsStorageEntry()
        {
            var testEntry = new Person(MockHelpers.GetRandomTestName(), this.testUser);

            Assert.IsTrue(testEntry.IsStorageEntry);
        }
Exemplo n.º 21
0
        public void NewPersonIsUntracked()
        {
            var testEntry = new Person(MockHelpers.GetRandomTestName(), this.testUser);

            Assert.False(testEntry.IsTracked);
        }
Exemplo n.º 22
0
 private Area CreateTestEntry(out string name, out string picture)
 {
     name    = MockHelpers.GetRandomTestName();
     picture = "/test/Picture.png";
     return(Area.CreateUnmodified(name, picture));
 }
Exemplo n.º 23
0
        public void NewPersonHasUserId()
        {
            var testEntry = new Person(MockHelpers.GetRandomTestName(), this.testUser);

            Assert.AreEqual(testEntry.UserId, this.testUser.Id);
        }
Exemplo n.º 24
0
        public void SetNewIconThrows()
        {
            var testEntry = this.CreateTestEntry(out _, out _, out var _, out _, out _);

            Assert.Throws <InvalidOperationException>(() => testEntry.Icon = MockHelpers.GetRandomTestName());
        }
Exemplo n.º 25
0
        public void NewAreaIsUntracked()
        {
            var testEntry = new Area(MockHelpers.GetRandomTestName());

            Assert.False(testEntry.IsTracked);
        }
Exemplo n.º 26
0
 private User CreateTestEntry(out string name)
 {
     name = MockHelpers.GetRandomTestName();
     return(User.CreateUnmodified("testId", name, false));
 }
Exemplo n.º 27
0
        public void NewZoneHasPendingChanges()
        {
            var testEntry = new Zone(MockHelpers.GetRandomTestName(), 20, 30, 5);

            Assert.IsTrue(testEntry.HasPendingChanges);
        }
Exemplo n.º 28
0
        public void SetNullOrWhiteSpaceNameWhenAcceptedDoesNotThrows(string value)
        {
            var testEntry = new NullNameTestRegistryEntry(MockHelpers.GetRandomTestName());

            Assert.DoesNotThrow(() => testEntry.Name = value);
        }
Exemplo n.º 29
0
        public void NewZoneIsUntracked()
        {
            var testEntry = new Zone(MockHelpers.GetRandomTestName(), 20, 30, 5);

            Assert.IsFalse(testEntry.IsTracked);
        }