3

I am using FakeDB trying to mock a media provider. I get this message when attempting the example shown in the wiki.

Starting from Sitecore 8.2, the Sitecore.Resources.Media.MediaProvider class is marked as obsolete and will be removed in the next major release. Please use new abstract type Sitecore.Abstractions.BaseMediaManager from the Sitecore.Kernel assembly.

How would this look in 8.2 exactly? I've tried the following but nothing is returned.

 var mediaProvider =
          Substitute.For<BaseMediaManager>();

        mediaProvider
          .GetMediaUrl(target)
          .Returns(expectedUri);

       // act
        var mediaUrl = Database.GetDatabase("master").GetItem(newID).MediaUrl(template.FieldId);

2 Answers 2

1

BaseMediaManager is an abstract class.

Try using Sitecore.Resources.Media.DefaultMediaManager which is derived class of BaseMediaManager

JustDecompile view

I'm using JustDecompile to see the class and inheritance chain of Sitecore classes.

1

The decision to obsolete the switchers was predicted by SitecoreAuthenticationProvider which became obsolete in 8.2:

/// <summary>SitecoreAuthenticationProvider class</summary>
[Obsolete]
public class SwitchingAuthenticationProvider : AuthenticationProvider

There was a wrong dependency on that class which has been fixed in v1.6.0. But it looks like it was a premature decision to obsolete the FakeDb classes. All the mentioned Sitecore providers are still valid and work fine (at least for 8.2 versions including Update-4). There is no reason in showing the warning.

The FakeDb switchers have been restored in v1.7.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.