Beispiel #1
0
        public void RetrieveNonExistentValue()
        {
            EAV.Store.Clients.IValueStoreClient client = factory.Create <EAV.Store.Clients.IValueStoreClient>();

            var value = client.RetrieveValue(-1, -1);

            Assert.IsNull(value, "Unexpected value object retrieved.");
        }
Beispiel #2
0
        public void RetrieveAllValues()
        {
            EAV.Store.Clients.IValueStoreClient client = factory.Create <EAV.Store.Clients.IValueStoreClient>();

            int nDbValues     = this.DbContext.Values.Count();
            int nClientValues = client.RetrieveValues(null, null).Count();

            Assert.AreEqual(nDbValues, nClientValues, "The number of values retrieved by the client does not match the number in the database.");
        }
Beispiel #3
0
        public void DeleteValue()
        {
            EAV.Store.Clients.IValueStoreClient client = factory.Create <EAV.Store.Clients.IValueStoreClient>();
            var valueKey = SelectRandomItem(RetrieveAvailableValueKeys());

            EAVStoreClient.Value dbValueIn = CreateValue(valueKey.AttributeID, valueKey.InstanceID, Guid.NewGuid().ToString());

            client.DeleteValue(dbValueIn.Attribute_ID, dbValueIn.Instance_ID);

            EAVStoreClient.Value dbValueOut = this.DbContext.Values.SingleOrDefault(it => it.Attribute_ID == dbValueIn.Attribute_ID && it.Instance_ID == dbValueIn.Instance_ID);

            Assert.IsNull(dbValueOut, "Failed to delete value for attribute ID {0} and instance ID {1} from the database.", dbValueIn.Attribute_ID, dbValueIn.Instance_ID);
        }
Beispiel #4
0
        public void RetrieveRandomValue()
        {
            EAVStoreClient.Value dbValue = SelectRandomItem(this.DbContext.Values);

            if (dbValue != null)
            {
                EAV.Store.Clients.IValueStoreClient client = factory.Create <EAV.Store.Clients.IValueStoreClient>();

                var value = client.RetrieveValue(dbValue.Attribute_ID, dbValue.Instance_ID);

                Assert.IsNotNull(value, "Failed to retrieve value [{0}, {1}].", dbValue.Attribute_ID, dbValue.Instance_ID);
                Assert.AreEqual(dbValue.Attribute_ID, value.AttributeID, "Attribute ID values do not match.");
                Assert.AreEqual(dbValue.Instance_ID, value.InstanceID, "Instance ID values do not match.");
            }
            else
            {
                Assert.Inconclusive("No values were found in the database.");
            }
        }
Beispiel #5
0
        public void UpdateValue()
        {
            var    dbValue  = SelectRandomItem(this.DbContext.Values.AsEnumerable().Where(it => it.Unit != null));
            string oldValue = dbValue.Raw_Value;

            EAV.Store.Clients.IValueStoreClient client = factory.Create <EAV.Store.Clients.IValueStoreClient>();

            var value = (EAVStoreLibrary.StoreValue)dbValue;

            value.RawValue = oldValue.Flip();

            client.UpdateValue(value);

            ResetDatabaseContext();

            dbValue = this.dbContext.Values.Single(it => it.Instance_ID == value.InstanceID && it.Attribute_ID == value.AttributeID);

            Assert.AreEqual(value.RawValue, dbValue.Raw_Value);
            Assert.AreNotEqual(oldValue, dbValue.Raw_Value);
        }
Beispiel #6
0
        public void CreateValue()
        {
            EAV.Store.Clients.IValueStoreClient client = factory.Create <EAV.Store.Clients.IValueStoreClient>();
            var    valueKey = SelectRandomItem(RetrieveAvailableValueKeys());
            string rawValue = Guid.NewGuid().ToString();

            EAV.Store.IStoreValue value = client.CreateValue(new EAVStoreLibrary.StoreValue()
            {
                RawValue = rawValue,
            }, valueKey.InstanceID, valueKey.AttributeID);

            Assert.IsNotNull(value, "Failed to create value with value '{0}' for instance ID {1} and attribute ID {2}.", rawValue, valueKey.InstanceID, valueKey.AttributeID);

            ResetDatabaseContext();

            var dbValue = this.DbContext.Values.SingleOrDefault(it => it.Instance_ID == valueKey.InstanceID && it.Attribute_ID == valueKey.AttributeID);

            Assert.IsNotNull(dbValue, String.Format("Failed to retrieve instance ID {0}, attribute ID {1} from the database.", value.InstanceID, value.AttributeID));

            Assert.AreEqual(value.RawValue, dbValue.Raw_Value, "Property 'RawValue' was not created correctly.");
        }