Ejemplo n.º 1
0
        protected override string LegendsDescription()
        {
            var timestring = base.LegendsDescription();

            return
                ($"{timestring} {Entity} formed in {Structure?.ToString() ?? StructureId.ToString()} in {Site?.AltName}.");
        }
Ejemplo n.º 2
0
        public void CompareTo_WhenEqualNullableInts_Returns0()
        {
            var x = StructureId.Create((int?)42);
            var y = StructureId.Create((int?)42);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 3
0
        public void CompareTo_WhenLongXisGreaterThanY_Returns1()
        {
            var x = StructureId.Create((long)20);
            var y = StructureId.Create((long)10);

            Assert.AreEqual(1, x.CompareTo(y));
        }
Ejemplo n.º 4
0
        public void CompareTo_WhenIntXisLessThanY_ReturnsMinus1()
        {
            var x = StructureId.Create(10);
            var y = StructureId.Create(20);

            Assert.AreEqual(-1, x.CompareTo(y));
        }
Ejemplo n.º 5
0
        public void CompareTo_WhenStringsDifferOnCasing_Returns0()
        {
            var x = StructureId.Create("foo");
            var y = StructureId.Create("FOO");

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 6
0
        public void CompareTo_WhenEqualStrings_Returns0()
        {
            var x = StructureId.Create("foo");
            var y = StructureId.Create("foo");

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 7
0
        public void CompareTo_WhenEqualNonNullableAndNullableLongs_Returns0()
        {
            var x = StructureId.Create((long?)42);
            var y = StructureId.Create((long)42);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 8
0
        public void CompareTo_WhenStringsAreNull_Returns0()
        {
            var x = StructureId.Create((string)null);
            var y = StructureId.Create((string)null);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 9
0
        public void CompareTo_WhenEqualNullableLongsAreNull_Returns0()
        {
            var x = StructureId.Create((long?)null);
            var y = StructureId.Create((long?)null);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 10
0
        public void GetSmallest_WhenXisGreaterThanY_ReturnsX()
        {
            var x = StructureId.Create(20);
            var y = StructureId.Create(10);

            Assert.AreEqual(y, StructureId.GetSmallest(x, y));
        }
Ejemplo n.º 11
0
        public void CompareTo_WhenStringXisGreaterThanY_Returns1()
        {
            var x = StructureId.Create("b");
            var y = StructureId.Create("a");

            Assert.AreEqual(1, x.CompareTo(y));
        }
 private IEnumerable <IStructureId> GenerateIds(int numOfIds)
 {
     for (var c = 0; c < numOfIds; c++)
     {
         yield return(StructureId.Create(SequentialGuid.New()));
     }
 }
Ejemplo n.º 13
0
        public override void UnitComplete(float quality)
        {
            if (!Active())
            {
                return;
            }

            ConsumeCostItems();
            var farmPlot = StructureId.GetStructure() as Farm;

            // change to new plant
            if (farmPlot.PlantName != Option.Name)
            {
                farmPlot.PlantName = Option.Name;
                farmPlot.ResetGrowth();
            }
            else
            {
                if (farmPlot.IsMature())
                {
                    farmPlot.SpawnYield();
                    farmPlot.ResetGrowth();
                }
                else
                {
                    farmPlot.Quality += quality;
                }
            }
        }
Ejemplo n.º 14
0
        public TileBlock start(int x, int y, StructureId id)
        {
            this.startX = x;
            this.startY = y;
            this.id     = id;

            return(getTileBlockAt(x, y));
        }
Ejemplo n.º 15
0
        public void CompareTo_WhenEqualNonNullableAndNullableGuids_Returns0()
        {
            var v = Guid.Parse("E72A0240-4B05-4678-B1DD-8CCBA10F8CA2");
            var x = StructureId.Create((Guid?)v);
            var y = StructureId.Create(v);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 16
0
 internal Structure GetStructure()
 {
     if (_structure == null)
     {
         _structure = StructureId.GetStructure();
     }
     return(_structure);
 }
Ejemplo n.º 17
0
        public override void UnitComplete(float quality)
        {
            ConsumeCostItems();

            var barrel = StructureId.GetStructure() as LiquidContainer;

            barrel.FillLevel = Mathf.Min(barrel.Capacity, barrel.FillLevel + 25);
        }
Ejemplo n.º 18
0
        public void CompareTo_WhenDifferentIdTypes_ThrowsException()
        {
            var x = StructureId.Create((int?)42);
            var y = StructureId.Create((long?)42);

            var ex = Assert.Throws <SisoDbException>(() => x.CompareTo(y));

            Assert.AreEqual(ExceptionMessages.StructureId_CompareTo_DifferentIdTypes, ex.Message);
        }
Ejemplo n.º 19
0
        public void Set_WhenFromIsNull_FromBecomesNewId()
        {
            var from     = StructureId.Create(1);
            var interval = new StructureIdInterval();

            interval.Set(from);

            Assert.AreEqual(from, interval.From);
        }
Ejemplo n.º 20
0
 public override bool Equals(Object obj)
 {
     if (obj is Executor ob)
     {
         return(Id.Equals(ob.Id) && Name.Equals(ob.Name) && ShortName.Equals(ob.ShortName) && Login.Equals(ob.Login) &&
                StructureId.Equals(ob.StructureId) && Activity.Equals(ob.Activity));
     }
     return(false);
 }
Ejemplo n.º 21
0
        public void Equals_WhenDifferentName_ReturnsFalse()
        {
            var          structureId = StructureId.Create(Guid.Parse("06E2FC67-AB9F-4E65-A2C8-5FC897597887"));
            const string thevalue    = "TheValue";

            var structure1 = new StructureIndex(structureId, "TheName", thevalue, thevalue.GetType(), _converter.Convert(CreateProperty(thevalue.GetType())));
            var structure2 = new StructureIndex(structureId, "TheOtherName", thevalue, thevalue.GetType(), _converter.Convert(CreateProperty(thevalue.GetType())));

            Assert.AreNotEqual(structure1, structure2);
        }
Ejemplo n.º 22
0
        public void Equals_WhenDifferentValue_ReturnsFalse()
        {
            var structureId  = StructureId.Create(Guid.Parse("06E2FC67-AB9F-4E65-A2C8-5FC897597887"));
            var dataType     = typeof(string);
            var dataTypeCode = _converter.Convert(CreateProperty(dataType));

            var structure1 = new StructureIndex(structureId, "TheName", "TheValue", dataType, dataTypeCode);
            var structure2 = new StructureIndex(structureId, "TheName", "OtherValue", dataType, dataTypeCode);

            Assert.AreNotEqual(structure1, structure2);
        }
Ejemplo n.º 23
0
        public void Equals_WhenDifferentGuidStructureId_ReturnsFalse()
        {
            var          structureId1 = StructureId.Create(Guid.Parse("06E2FC67-AB9F-4E65-A2C8-5FC897597887"));
            var          structureId2 = StructureId.Create(Guid.Parse("14D4D3EC-6E1E-4839-ACC7-EA3B4653CF96"));
            const string thevalue     = "TheValue";

            var structure1 = new StructureIndex(structureId1, "TheName", thevalue, thevalue.GetType(), _converter.Convert(CreateProperty(thevalue.GetType())));
            var structure2 = new StructureIndex(structureId2, "TheName", thevalue, thevalue.GetType(), _converter.Convert(CreateProperty(thevalue.GetType())));

            Assert.AreNotEqual(structure1, structure2);
        }
Ejemplo n.º 24
0
        public virtual IStructureId[] Generate(IStructureSchema structureSchema, int numOfIds)
        {
            var structureIds = new IStructureId[numOfIds];

            for (var c = 0; c < structureIds.Length; c++)
            {
                structureIds[c] = StructureId.Create(GenerateComb());
            }

            return(structureIds);
        }
Ejemplo n.º 25
0
        public void Create_WhenNullableIntNotNull_ValuesAreReflected()
        {
            int?value = int.MaxValue;

            var id = StructureId.Create(value);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(int?), id.DataType);
            Assert.AreEqual(StructureIdTypes.Identity, id.IdType);
        }
Ejemplo n.º 26
0
        public void Create_WhenLong_ValuesAreReflected()
        {
            var value = long.MaxValue;

            var id = StructureId.Create(value);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(long), id.DataType);
            Assert.AreEqual(StructureIdTypes.BigIdentity, id.IdType);
        }
Ejemplo n.º 27
0
        public void ShouldGenerateUniqueIdForNewLevel()
        {
            var structureId = new StructureId();

            var structure      = new Structure(structureId);
            var level1         = structure.CreateLevel("Level 1", Enumerable.Empty <ILevel>());
            var existingLevels = new[] { level1 };
            var level2         = structure.CreateLevel("Level 2", existingLevels);

            level1.Id.Should().NotBe(level2.Id);
        }
Ejemplo n.º 28
0
        public void Create_WhenNullableLongBeingNull_ValuesAreReflected()
        {
            long?value = null;

            var id = StructureId.Create(value);

            Assert.IsTrue(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(long?), id.DataType);
            Assert.AreEqual(StructureIdTypes.BigIdentity, id.IdType);
        }
Ejemplo n.º 29
0
        public void Create_WhenGuidAsObject_WithSpecificIdType_ValuesAreReflected()
        {
            object value = Guid.Parse("ec20922b-195e-4787-89a8-68bc2b4c0fe6");

            var id = StructureId.Create(value, StructureIdTypes.Guid);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(Guid), id.DataType);
            Assert.AreEqual(StructureIdTypes.Guid, id.IdType);
        }
Ejemplo n.º 30
0
        public void ConvertFrom_WhenLongAsObject_ValuesAreReflected()
        {
            long value = 42;

            var id = StructureId.ConvertFrom(value);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(long), id.DataType);
            Assert.AreEqual(StructureIdTypes.BigIdentity, id.IdType);
        }