Hi Marc,

thanks a lot. So, this is the class (I deleted anything not needed for 
the test, so I am not sure, if it will compile like that):

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using System.Security;
using System.Security.Principal;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using NDO;
using log4net;
using Brenk.Microkernel;
using Brenk.Compas.Contracts;
using Brenk.Compas.RightsManagement.Properties;

namespace Brenk.Compas.RightsManagement
{
   [HasSelfValidation]
    public class CompasIdentity : ICompasIdentity
    {

        #region private Felder
        /// <summary>
        /// UserName (ID)
        /// </summary>
        private string m_name;


  
        [SelfValidation]
        private void CheckName (ValidationResults ergebnisse)
        {
            
m_Log.Info(System.Reflection.MethodBase.GetCurrentMethod().Name);
            if ( m_name == null || m_name.Trim().Length < 1 || 
m_name.Trim().Length > 50 )
            {
                ergebnisse.AddResult(new 
ValidationResult(Properties.Resources.UserNameValid, this, null, null, 
null));
            }
        }
     

        /// <summary>
        /// Liefert den Namen der Identität zurück
        /// </summary>
        ///<remarks> Tests in Klasse ICompasIdentity_CombiTest, Methoden 
beginnend mit SetName</remarks>
        public string Name
        {
            get { return m_name; }
         
        }
    
        /// <summary>
        /// Setzt den Namen der Identity, prüft dabei aber, ob schon 
gesetzt.
        /// Name wird nicht überschrieben
        /// </summary>
        /// <param name="name">Name</param>
        /// <returns>Bool (Setzen erfolgreich/nicht gesetzt, weil schon 
belegt)</returns>
        /// <exception cref="ArgumentException">ArgumentException, wenn 
Name==Null oder Name Empty oder Name länger als 50 Zeichen</exception>
        /// <remarks>Tests in Klasse ICompasidentity_CombiTest, Methoden 
beginnend mit SetName</remarks>
        public virtual bool SetName (string name)
        {
            
m_Log.Info(System.Reflection.MethodBase.GetCurrentMethod().Name);
            if ( m_name == null || m_name.Trim().Length == 0 )
            {
                m_name = name;
                ValidationResults ergebnisse = new ValidationResults();
                CheckName(ergebnisse);
                if ( ergebnisse.IsValid )
                {
                    return true;
                }
                else
                {
                    m_name = null;
                    throw new 
ArgumentException(Properties.Resources.UserNameValid);
                }
            }
            else
            {
                return false;
            }
        }

  
    }
}


*this ist the test:*

/// <summary>
        /// Name soll mit gültigem Wert gesetzt werden, sollte klappen.
        /// Problem: Identity-Objekt für alle Tests hier gleich, Name 
wird nicht zurückgesetzt.
        /// </summary>
        /// <param name="cid">ICompasIdentity ohne Name</param>
        /// <param name="name">Gültige Strings für Name</param>
        [CombinatorialTest]
        public void SetNameKlappt 
([UsingFactories("GetIdentityOhneName")] ICompasIdentity cid, 
[UsingFactories("MakeCorrectName")] string name)
        {
            Assert.IsTrue(cid.SetName(name),name+" ist 
"+name.Length.ToString()+" Zeichen lang. Username:"+cid.Name);
            Assert.AreEqual(cid.Name, name);
        }
* here are the Factories:*

/// <summary>
        /// Name soll mit gültigem Wert gesetzt werden, sollte klappen.
        /// Problem: Identity-Objekt für alle Tests hier gleich, Name 
wird nicht zurückgesetzt.
        /// </summary>
        /// <param name="cid">ICompasIdentity ohne Name</param>
        /// <param name="name">Gültige Strings für Name</param>
        [CombinatorialTest]
        public void SetNameKlappt 
([UsingFactories("GetIdentityOhneName")] ICompasIdentity cid, 
[UsingFactories("MakeCorrectName")] string name)
        {
            Assert.IsTrue(cid.SetName(name),name+" ist 
"+name.Length.ToString()+" Zeichen lang. Username:"+cid.Name);
            Assert.AreEqual(cid.Name, name);
        }
/// <summary>
        /// Erzeugt gültige Namens-Strings
        /// </summary>
        /// <returns>String mit gültigen Namen</returns>
        [Factory(typeof(string))]
        public IEnumerable MakeCorrectName()
        {
            yield return "Haider";
            yield return "R".PadRight(49,'r');
            yield return "rr";
        }

Thanks for your help!!!

Claudia

Marc schrieb:
> Hi Claudia,
>
> This sounds like the sort of thing I've done with a combinatorial
> test. It might help if you could post your code?
>
> - Marc
>
> On May 23, 7:42 am, querpfeife <[EMAIL PROTECTED]> wrote:
>   
>> Hi there,
>>
>> I am testing an interface, using MbUnit's combinatorial test. The Test
>> uses a method to set a field (called name). The Method is meant to be
>> used only once. Thus it will return false and not change the value of
>> "name" if there is already a value.
>>
>> The Test combines one instance of the tested class (with empty field
>> "name") with several values for the string being set by the method
>> "SetName(string name)".
>> First time everything works fine, but the second test fails, because the
>> name-Field is set and MbUnit uses the same instance of the class. I
>> thought a combinatorial test would start with a "fresh" instance
>> provided from the factory for every single test.
>>
>> What's wrong about my test? Please help!
>>
>> Thank's a lot
>>
>> Claudia
>>     
>
>
> >
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/MbUnitUser?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to